simplifying commands?

tk4two1

Professional Crastinator
I was wondering how to go about simplifying my most used commands. Basically if I want to run a command like
Code:
ls -a -s -l
but I only want to type
Code:
list
or something like that, how do I go about this? Is it using links and what not? Please help me. Thanks!
 
use the "alias" shell builtin. So, by making a file in your home dir called .bash_profile, and putting lines in it like
alias list='ls -a -s -l'
you can save some typing

Incidentally, that file is only read once when bash starts, so that will apply only to terminal windows opened since you change the file
 
thanks That was exactly what I was looking for! :D

By the way what other types of entries can I put in the .bash_profile?
 
Pretty much anything you can write on the command line, I believe. Oh, by the way
ls -a -s -l
can also be written
ls -asl
 
Yes, you can put anything you want in there - it's just a script that gets run whenever the shell starts.

I don't actually use bash - I got set in my ways in OS X PB - 10.2 where tcsh was the default shell. I decided to try bash for a while, and made this bash_profile before I got fed up with it:

#shell behaviour

# set prompt string to something informative...
# bold seems to be messing up character wrapping in Apple's terminal. Errr
# but we can still write to the title line without problems.

#bold=`tput bold`
#plain=`tput sgr0`
bold=''
plain=''
titlebar='\[\033]0;\u@\h:\w\007\]'

PS1="${titlebar}${bold}$? \A \u@\h:\W \$${plain}"
export PS1

# make tab completion more useful
set autolist = ambiguous

##conveniences
alias ll='ls -al'
alias l='ls -FH'
alias ..='cd ..'
alias ps2pdf='pstopdf'
alias du='du -h'

# line <number> <filename>
line() {
cat $2 | sed -n "$1 p"
}

mkcd() {
mkdir $1
cd $1
}


##environmental friendliness
#why vi?
export EDITOR=nano
# set this, and manpages don't close without explicit 'q'
export PAGER=less

Should give you at least an idea of what sort of thing can go in there
 
Back
Top