LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   creating alias (https://www.linuxquestions.org/questions/debian-26/creating-alias-629466/)

kaplan71 03-20-2008 10:12 AM

creating alias
 
Hi there --

I want to create an alias and my first choice is to modify the .bashrc file. However, according to the documentation there, it is recommended that I create a .bash_aliases file and add the alias there.

Has anyone done it this way, and besides creating the file what else do I need to do in order to get the alias to work properly? Thanks.

b1f30 03-20-2008 10:30 AM

Here's an example that I use for Bash in Debian:

Code:

# echo "alias ls='ls -lha'" >> ~/.bashrc
# source ~/.bashrc

Give it a shot.

I'm not sure why the documentation recommends that you put aliases elsewhere. I've personally never done it that way, but perhaps there is a reason.

marozsas 03-20-2008 12:14 PM

To avoid the .bashrc becomes cluttered with so many commands, I choose (a personal choice) to put aliases in a separated file.

in ~/.bashrc:
Code:

test -s ~/.alias && . ~/.alias || true
in ~/.alias:
Code:

alias a=alias
a h=history
a ll='ls -l'

In this way it is easy to just edit .alias to add/modify an alias.

But as I said, it is a personal choice. Putting aliases inside .bashrc as b1f30 did is just fine too.


All times are GMT -5. The time now is 05:26 PM.