Posts

Showing posts with the label linux

Make your bash script runnable from every directory on the terminal

Have you ever wanted to create a utility like ls for example and make it available from everywhere in the linux's/mac's terminal? There two ways to do that. Way 1 (lets assume that my script is in a file with the name hello.) a.move your script to /bin sudo mv hello /bin/hello b.make your script executable sudo chmod +x /bin/hello you are ready to ramble! Way 2 create a file with different functions and aliases like the example bellow. Lets assume that the file name is .myfunc the file might look like: Now on your home directory find a file called .bashrc . If you are using a different shell (like zsh) the file might be different. For example if you are using zsh you should look for . zshrc . Mind that the file names starting with dot (.) in POSIX systems (like linux and macOs) are hidden files. when you find the file .bashrc, edit it with VI or the editor of your choice and add somewhere (it does not matter where) the line source {path to yo...