2

I want to know if it's possible to create keywords (similar to workflow keywords in alfred) for certain terminal commands. For example instead of typing:

php artisan serve

I want to type:

pas

while executing the above command.

  • 1
    Make alias or function in appropriate rc file. – Aivar Paalberg Dec 05 '21 at 09:40
  • Alias is the way to go. Just a small tip. I find the following very convenient: Every system modification that I make including aliases, custom shell scripts or executables, I store in Documents folder structure, for example: ./Documents/Commands/myCustomCommand. This way your own custom work is safely stored in the cloud and makes migration and life a little bit easier. – Gintaras Dec 05 '21 at 10:42
  • Why does putting it in $HOME/Documents mean it's stored in the cloud, or that it would be "safe" if it were? – Marc Wilson Dec 05 '21 at 17:08
  • If you have iCloud account, documents folder can be synced with Apple's cloud storage. Are we discussing why cloud services are safe way to store documents? https://www.apple.com/icloud/ iCloud is built into every Apple device. That means all your stuff — photos, files, notes, and more — is safe, up to date, and available wherever you are. – Gintaras Dec 05 '21 at 20:03
  • @Gintaras It's certainly well worth considering what would happen if a HD/SSD or machine died, and ensuring that you wouldn't lose anything important. (But iCloud is far from the only way to achieve that.) – gidds Dec 05 '21 at 22:06

1 Answers1

7

The ‘alias’ command defines aliases.

alias pas="php artisan serve"

The default shell is now zsh so you define this in ~/.zshrc.
Source the file . ~/.zshrc for the change to take effect in the current shell.

Previously, you would define this in ~/.bash_profile. If you updated from an older version of macOS and haven’t changed your shell from bash to zsh as prompted, you’ll still need to use ~/.bash_profile.

grg
  • 192,762
  • 43
  • 337
  • 460