I make bash/ruby commands for basically everything in my development workflow ( todo
, pullrequest
, asciiart
, remind
and so on). People I work with always ask me to share my commands with them, but to do this, I transfer the files to their computer, then xargs
through each file with chmod +x
and mv /usr/local/bin
.
Wondering what work I can do upfront to make the import process easier. Fine with some Mac installer tool, or a git & makefile solution, but I'd really like to get the process down to a single click or command if possible.
Use Nix expressions with Nix package manager: https://en.m.wikipedia.org/wiki/Nix_package_manager ! It is supported on Macs.
It is possible to make a Terminal command executable by just selecting it in Finder and pressing the keyboard shortcut.
Below is the method for solving your problem.
1. Create a macOS service using Automator
1.1 Open Automator and create a new service
1.2 At the top, choose Service receives selected no input
in Finder
1.3 Drag Get Selected Finder Items action to the workflow
1.4 Drag Run Shell Script action to the workflow
1.5 In Run Shell Script action, select Pass input: as arguments
and in the text field, type:
chmod u+x "$@" && mv "$@" /usr/local/bin
1.6 Save service
2. Distribute service to colleagues' computers
2.1 The created service is located in ~/Library/Services
2.2 Move it to other computers and install it by opening the file, or manually copying the service to ~/Library/Services
3. Bind service to a keyboard shortcut
3.1 Open System Preferences → Keyboard → Shortcuts → Services → General
3.2 Choose an appropriate keyboard shortcut for your service
You can also run the service by right-clicking on file and selecting the action in Services submenu at the bottom of contextual menu.
Share a Dropbox directory with them that contains your scripts, and ensure that it is in their PATH
.
No updates are necessary when you improve your scripts as they will automatically see the latest version.
Manage the directory with git
for version control.
Thought I'd post the standard makefile solution for completion sake. Works for macOS/ and GNU(Linux)
Put a makefile in the project directory.
So the directory looks like [ my-executable
makefile
readme.md ]
or whatever
# makefile
install:
# side note: `@` prevents make from printing the command itself
@echo "installing..."
@chmod +x my-executable
@cp my-executable /usr/local/bin
@echo "done!"
then inform recipients to download/clone and run sudo make install
from the project directory
Or for a one-line solution (presuming the recipients trust you a little too much)
git clone https://githost.com/myaccount/myrepo.git &&
sudo make install -C myrepo &&
rm -rf myrepo
(download, install, remove cloned directory) – user 16 mins ago
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.