Skip to content

Instantly share code, notes, and snippets.

@maxjowett
Last active May 7, 2020 04:02
Show Gist options
  • Save maxjowett/1abde81ed60aba5f4488a1303af00517 to your computer and use it in GitHub Desktop.
Save maxjowett/1abde81ed60aba5f4488a1303af00517 to your computer and use it in GitHub Desktop.
#!/bin/bash
open -na "/Applications/Google Chrome.app" "https://www.youtube.com/watch?v=5qap5aO4i9A"
echo Enjoy!
@maxjowett
Copy link
Author

maxjowett commented May 7, 2020

To run a script your OS will look through directories in your $PATH. Rather than adding your script to folders containing low level utilities such as ls or cd, I would suggest making your own personal directory.

cd ~ and mkdir scripts

Since macOS has switched to ZSH as it's default shell, we will edit .zshrc, typically found here: /Users/<your_username>/.zshrc. Not sure what your username is? Run whoami in your terminal.

Chances are all it currently contains is something along the lines of:
export PATH=$HOME/bin:/usr/local/bin:$PATH

If thats the case, you're in good shape! Add the following line below:
path+=(/Users/<your_username>/scripts)

Save the file, and run source ~/.zshrc.

Last but not least, once you add a script to the scripts folder, navigate into your scripts folder and run chmod +x <filename> to mark the script as executable.

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment