Making an alias in the shell


#1

I’m NOT new to UNIX or a shell. I’m new to customizing my experience. I read that I can make “ls” be an alias of “ls -lh”

I read to add the following line to .bashrc
alias ls=‘ls -lh’

I did so, exited, came back in the shell and it doesn’t work. Does anyone know how to do this?

I’d also like to try:
alias dir=‘ls -la’

Thanks


#2

This is what I use: alias ls=‘ls -AF’

‘F’ puts little characters at the end of file names depending on what type of file it is. * for executables, / for directores, @ for softlinks and nothing for regular files. ‘A’ is the same as ‘a’ but it doesn’t show . or …

And speaking of “aliases”, they’re called softlinks in *nix terms. :slight_smile:

You can also use man to find out a bunch of stuff: man ls


yerba# rm -rf /etc
yerba#


#3

well, first off .bashrc, as it says at the top of the file " executed by bash(1) for non-login shells." You need to add that line to .bash_profile.

You might also enjoy:
alias ls=‘ls --color=auto’

if you ssh client supports it, it makes directory lists colorful.

Edit: also, .bash_profile is only excuted at login, so you’ll have to log out and then back in to see it take effect. Not sure if you knew that or not - but I’d rahter point it out anyways. :slight_smile:

–Matttail
art.googlies.net - personal website


#4

And speaking of “aliases”, they’re called softlinks in *nix terms.

Assuming you’re referring to the file type more commonly known as symbolic links (aka, symlinks), then no, they are completely different.

An alias is an environement setting that will make one command execute a different one (for example, what the original poster here is doing). A symlink is a file that refers to a file or directory elsewhere on the system.


If you want useful replies, ask smart questions.


#5

doh! For some reason when he mentioned making aliases, I immediately thought of a windows user trying to create an “alias” on the command line. :slight_smile:

Yeah, my previous comment is incorrect. Stupid me.


yerba# rm -rf /etc
yerba#


#6

Thanks to everyone.
I’m not sure what it’s called, but I figured out what I wanted to do. I edited the “.alias” file to read:

alias ls 'ls -lh’
alias md mkdir
alias rd rmdir
alias dir ‘ls -la’

I’m using tcsh, so maybe that’s why I needed to use this file, instead of “.bashrc” and “.bash_profile”

Thanks.


#7

yeah. Different shells use different profile files. Different shells also have different methods of defining variables, too, as you’ve also found out (not = in tcsh).


yerba# rm -rf /etc
yerba#