I’m assuming here that you are on a POSIX compliant system (namely OSX or Linux). First let’s make sure we are in our home directory. On OSX or Linux in a terminal run:
Standard practice is to keep user shell scripts in a bin folder in your home directory. You may or may not have this folder depending on your operating system. If it doesn’t exist create it:
So on OSX the folder path will be
/Users/george/bin. On Linux it will be
/home/george/bin. Remember ‘george’ will be whatever your username is.
To be able to use the shell scripts from our
bin folder we need to make sure that this folder is in the
$PATH variable. The shell looks in this folder when you issue a command.
If you are comfortable with vi use these commands. If you are not comfortable with vi use your text editor of choice.
cd #change to home directory vi .bash_profile
Add the following line to this file
For the changes to take effect you need to reload your profile. I’m assuming you are still in your home directory.
Now we can just drop shell scripts into the bin folder. To use them we must make sure they are executable: chmod +x yourshellscript.sh
That’s it. Now you can call your shell script from the command line using
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Listening to BBC Radio with mpv
The BBC publishes high quality 320 kbps HLS AAC streams that can be used to listen to radio from the command-line using mpv. Here are the URLs and some aliases to start listening quickly.
Vim: So long Pathogen, hello native package loading
Vim 8 added a native way to load third-party packages. This means, for me at least, there is no longer any need to use a third party plugin helper like Pathogen.
Linux and Unix more command tutorial with examples
Tutorial on using more, a UNIX and Linux command for viewing the contents of a file or files one screen at a time. Examples of viewing a file, viewing multiple files, searching using regular expressions and opening the file in a text editor.