Reputation: 1
I would like to customize a Mac terminal command.
For example, regardless the directory I am in, whenever I type 'task1' on command prompt and then enter, it will automatically execute the terminal commands that wrote in a .sh file saved at a location.
I am overwhelmed, I can only run the .sh file by providing its location, which is longer than a 'task1' command.
Upvotes: 0
Views: 287
Reputation: 7777
Put the script in your PATH. You can find a suitable location with echo $PATH
, and put the script in one of those directories. If none of them look good to you, you can make a new directory somewhere, for example $HOME/bin
, put the script there, and add PATH="$HOME/bin:$PATH"
to your .bash_profile
or .zprofile
, depending on what shell you're using. If you search on StackOverflow for questions related to how PATH works you'll find a lot of good info.
Upvotes: 1