E.g.:

echo 'alias myip="curl -s "http://checkip.dyndns.org/" | grep -o "[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*" | head -1"' >> /home/USER/.bash_profile

when I type "myip" then I will get my public IP address

link|improve this question

62% accept rate
Whatever you regularly would type anyway. Better ask for useful bash commands, but I'm pretty sure that's already available somewhere. – Daniel Beck May 13 '11 at 16:28
Do you only want aliases, or are functions acceptable? – Ignacio Vazquez-Abrams May 13 '11 at 16:38
functions could come too, yes!! :) – LanceBaynes May 13 '11 at 16:48
2  
You should generally put aliases in ~/.bashrc and not in ~/.bash_profile because aliases are not exported and hence not inherited by child shells. – garyjohn May 13 '11 at 17:02
If you Google .bashrc you will find tons of samples. When I was learning unix initially I found these and copied in quite a few to my .bashrc file. After some time I slowly trimmed down what i had added because I had no clue of some of the functionality of the things i had added. I then started adding shorcuts to commands i would use daily but where too long to type out repetitively. You sort of defeat the purpose of creating the aliases if you have to study to alias file to figure out what a particular command does. – mike G May 13 '11 at 17:49
show 1 more comment
feedback

closed as not constructive by Daniel Beck, Wuffers, slhck, Hello71, Nifle May 14 '11 at 14:15

This question is not a good fit to our Q&A format. We expect answers to generally involve facts, references, or specific expertise; this question will likely solicit opinion, debate, arguments, polling, or extended discussion. See the FAQ for guidance on how to improve it.

2 Answers

Here are a few of my aliases.

when I want to open a file with the GUI, i type go filename

alias go='xdg-open'

reccords the desktop with ffmpeg, and save to the specified file

alias recordDesktop='ffmpeg -f x11grab -s 800x600 -r 25 -i :0.0 -sameq'

Starts a simple http server with python

alias simpleServer='python -m SimpleHTTPServer'

Color in grep :

alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto' 

Aliases for ls alias ldir='ls -d */' alias lgrep='ls | grep' alias l='ls -CF' alias la='ls -A' alias ls='ls --color=auto' alias lx='ls -CFlash'

Start and stop lampp

alias lamppstart='sudo /opt/lampp/lampp start'
alias lamppstop='sudo /opt/lampp/lampp stop'

sl is always fun when you typo ls, but you want to be able to interrupt it, since it's not interruptable by default.

alias sl='sl -e'

Aliases for the vim server

alias vimc='vim --remote-tab-silent'
alias vims='vim --servername VIM'

I have this in my ~/.bash_functions, to scrape files from a website :

function wget_scrape {
   wget -r -l1 -np -A.$1 -nd $2
}

just a note, if you have many aliases, you may want to define them in ~/.bash_aliases, and add this somewhere in ~/.bashrc (i think it's there by default in ubuntu) :

if [ -f ~/.bash_aliases ]; then
     . ~/.bash_aliases
fi
link|improve this answer
feedback

The only one I have that I really care about (doesn't always do a perfect job though):

cless() {
  echo -en '\033]2;Viewing: '"$1"'\007' 1>&2
  pygmentize -f terminal "$1" | less -R
}
link|improve this answer
feedback

Not the answer you're looking for? Browse other questions tagged or ask your own question.