Adding an alias to the Bash Shell

Posted by Jason Noble on 09/14/2008 in Uncategorized |

If you run a command frequently, you can create what is called an alias. The alias is usually a shorter form of the original command.

To make these aliases permament, you should edit .bashrc in your home directory.

[text]
11:32:07 /Users/jasonn $ vi ~/.bashrc
[/text]

Add a line of text of the format “alias YYY=’ZZZ'” where YYY is the command you want to type in, and ZZZ is the command you want to be run.

Examples:

[text]
# Show long listing
alias ll=’ls -al’

# Use VI Improved instead of Vi
alias vi=’vim’

# Change into your web directory
alias web=’cd /usr/local/apache/vhosts/jasonnoble.org/htdocs’
[/text]

This alias ability allows you to type less at your shell prompt. If you find yourself typing the same long command line over and over, try adding an alias to your shell that will save you some time.

Copyright © 2008-2024 Jason Noble's Technical Adventures All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.