Terminal Tip - Aliases

If you’re like me, and use a few terminal commands on a daily basis, and you hate typing them. This tip is for you. This is an example of creating an “alias” for a frequently used, or hard to remember command. In this example I will be creating a “shortcut” to a ssh session. However, you can type any command between the quotes in step 3.

  1. While inside your home directory (/Users/yourusername).
  2. Type nano .bashrc this will open the text editor and you will see maybe a few lines, maybe nothing.
  3. Type alias shell=”ssh user@server” (replace “shell” with whatever you want your alias to be)
  4. Hit ctrl+x and then y and return to save this.
  5. Type source ~/.bashrc - This will reload the .bashrc for your shell.
  6. After you do everything you need to add source ~/.bashrc to .bash_profile in /Users/yourusername/ to make sure it’s loaded at login.

Now, when you open a terminal, just type shell and your ssh session will start. I use this for everything, I have aliases for ten ssh shells, two Macfuse mounts, and I use the alias r for screen -r to quickly attach back to a screen session that has detached.


 
 

One Response to “Terminal Tip - Aliases”


  1. Trackback
    le blog à Ollie » Liens du jour

    [...] Astuce pour Terminal (Mac): créer un alias de commande. [...]


Post a comment to "Terminal Tip - Aliases"



Support MacTips

MacTips Newsletter


Random Popular Tips

Recent Comments

Recent Discussions

MacTips Poll

What level of tips would you like to see?

View Results

Loading ... Loading ...

Friends of MacTips

Subscribe to MacTips

Site Links