share
Super UserUseful command-line aliases?
[+42] [55] MiffTheFox
[2009-07-17 14:01:55]
[ linux command-line bash shell alias ]
[ http://superuser.com/questions/7083] [DELETED]

I've been wondering what command-line aliases (such as in bash, or just even .bat files under Windows) you can't live without?

I'll start off with my favourite:

alias q=exit
(13) Maybe you already know it, but you can use Ctrl-D on any Unix shell to exit. - Jazz
@Jazz Yes, but I like to keep my commands consistent across both Unix and Windows. - MiffTheFox
"alias q=exit" That's an oops that's just waiting to happen...over and over. I set export IGNOREEOF="2" in order to avoid a similar uh-oh. - Dennis Williamson
@Dennis - It's an accident that I hit two seperate keys on complete different sides of my keyboard without hitting anything else? - MiffTheFox
[+35] [2009-07-17 14:14:37] BigBlackDog

i love the shorthands in my bash:

ll = ls -l 
la = ls -la

Can't live without 'em. - Tomas Sedovic
I also have l = ls -ltrA and lsd = ls -AtlLr | grep ^d - reinierpost
1
[+26] [2009-08-05 20:16:34] kitt

I rarely cd to a location without wanting to cd back, so I use pushd and popd a lot.

alias d='dirs -v'
alias pu=pushd
alias po=popd

Because cutting and pasting is good when you do similar tasks:

alias hg='history | grep $1'

Or see what's running:

alias psg='ps -ef | grep $1'

Because I frequently miss a space:

alias ls-al='ls -al'
alias cd..='cd ..'

And transpose letters:

alias csv=cvs
alias snv=svn

And, before svn had a no-whitespace diff, I started using this, and still do:

alias svndiff='svn diff --diff-cmd=`which diff` -x -w $1'

(9) +1 for the transpose letters, I always tpye wrogn - Decio Lira
+1 for pushd and popd, two utilities that I don't use nearly enough. - Babu
Try zsh with auto pushd, its pretty trick. :) - KFro
(10) hg is Mercurial.. That would be a bad choice for an alias for me. - eleven81
(1) What does pushd do that 'cd -' doesn't? - DoR
(7) $1 in an alias does not do what you think it does. alias psg='ps -ef | grep $1' is equivalent to alias psg='ps -ef | grep'. The $1 is not actually expanded. If you need positional parameters use a shell function, not an alias. - user23307
Heh, it's like #define flase false. I've seen that around a bit. - CamJackson
2
[+22] [2009-08-05 14:48:37] Jonik
alias ls='ls --color=auto'

...to get colour-coded directory listings.


(1) and alias ls='ls -F' to undo that and show characters to denote directories, executables, symbolic links, etc - Doug Harris
3
[+20] [2009-07-17 14:09:58] Telemachus

My two favorites are meta-aliases:

alias realias='vim ~/.bash_aliases; source ~/.bash_aliases'
alias refunction='vim ~/.bash_functions; source ~/.bash_functions'

This allows me to type realias or refunction, write a new alias or function in vim, and as soon as I close vim, the alias or function file is sourced so that the new item is instantly available.


Awesome dude! I just applied this - hasen j
The day I started doing the same kind of alias, I realized it was too late for me to be saved from them. - Gnoupi
I even have an edit_aliases alias :-) - compie
4
[+10] [2009-07-17 14:24:24] chaos
cdd = cd /wherever/i/am/most/likely/to/be/working/on/this/machine

5
[+10] [2009-08-14 01:10:12] chris

Saves me the most keystrokes:

alias ..='cd ..'
alias .='echo $PWD'

(6) On some shells, . does the work of source e.g . filename == source filename. - nagul
6
[+10] [2009-08-05 21:19:05] bmb

Not strictly an alias, but a bash function in my .bashrc file:

ff () { find . -name "*$1*" -print; }

7
[+8] [2009-10-02 16:55:21] Sidnicious

Show listening ports on this machine

alias openports='sudo lsof -i -P | grep -i "listen"'

Everybody loves screen

alias sre="screen -xr"

My own take on these [1]

alias l='ls -lA'
alias la='ls -laA'

Change to and list directory

function cdl { cd $1; l; }

Create and change to directory

function mkcd {
    if [ $# -ne 1 ]; then 
    	echo "usage: mkcd directory_name"
    elif [ -d "${1}" ]; then
    	echo "(directory already existed)"
    	cd "$1"
    elif [ -e "${1}" ]; then
    	echo "file exists"
    else
    	mkdir "${1}" && cd "${1}"
    fi
}

Remove working directory, if it's empty

function rmwd {
    if (shopt -s nullglob dotglob; f=(*); ((! ${#f[@]}))); then
    	# directory is empty
    	rmdir `"pwd"`
    	cd ..
    else
    	echo "not empty"
    fi
}
[1] http://superuser.com/questions/7083/useful-command-line-aliases/7103#7103

+1: I like the change and list directory - makes sense as I always use these two together. - Umber Ferrule
8
[+7] [2009-08-05 13:04:37] Adam Matan
alias sair='sudo aptitude install --with-recommends'
alias srch='apt-cache search'

Lovely for any Ubuntu or Debian system.


9
[+7] [2009-08-05 14:39:03] Lars Haugseth

A few picked from my .bash_aliases:

alias l="ls -l"
alias la="ls -la"
alias m="less"
alias p="cd .."
alias as="aptitude search"
alias ai="sudo aptitude install"
alias df="df -hT | grep -v tmpfs"
alias mk="make"
alias mki="sudo make install"
alias rmbak="rm ./*~"

(7) Is "make" really that long that it needs an alias? - tj111
(8) Well, mkdir is shortened to md, copy is shortened to cp, and move is shortened to mv. And don't get me started about usr... - Hello71
Alias says, 'Set it up how you like it!' - Umber Ferrule
10
[+6] [2009-08-05 15:27:35] jweede

On windows I always have to make a ls.bat file with dir inside. I just can't get used to typing dir everytime I want to see directory contents.

Cywgin [1] has also saved me much headache in going between windows and my preferred unix variants.

[1] http://www.cygwin.com/

contents of ls.bat: dir %1 %2 %3 %4 %5 %6 %7 %8 %9 - shufler
shufler: I'd suggest dir %* - Joey
PowerShell also has support for ls builtin. It's an alias to Get-ChildItem, but it's still nice. - James Deville
(3) Check out UnxUtils - sourceforge.net/projects/unxutils. Win32 binaries of some of the most common *nix command line commands. One of the first things I install on my system. - Matt
11
[+5] [2009-08-05 14:56:35] Jonik

Another "must-have" for me:

alias df='df -h'
alias du='du -h'

To automatically get human-readable disk usage information, e.g. "3.9G" instead of "4040808" (bytes).

Another example: which of these listings do you find easier to take in with a quick glance?

/dev/md1              61519828  28402280  29992508  49% /
tmpfs                  4099328         8   4099320   1% /lib/init/rw
/dev/mapper/vg0-opt  123854820  74758216  42805404  64% /opt

/dev/md1                   59G       28G       29G  49% /
tmpfs                     4,0G      8,0K      4,0G   1% /lib/init/rw
/dev/mapper/vg0-opt       119G       72G       41G  64% /opt

(1) You mean you can't convert 4040808 to 3.9GB in your head? ;-) - Lucas McCoy
(1) I could, yes, but I rather leave such mundane conversions to the computer, and bother my brain with something more interesting. I expanded the answer with an example. (I saw the smiley, but couldn't help responding. :-) - Jonik
12
[+4] [2009-08-05 20:34:42] voyager

On linux

alias x ='startx'

On windows

alias ls ='dir'

I've made a 33% optimization!


Omg ls='dir' would be so helpful ... why didnt I think of that >.< - Nippysaurus
(6) On "Ye Old Days", when Unix was all the rage, and IBM though that "Microcomputers" where too slow to be relevant many people had to go from Unix to (DR/PC/MS)DOS and found themselves typing dir under Unix, or ls under DOS. Of course there where some that replaced common commands to work uniformely, but this "abstraction" leaks too much for my taste. Getting a Command not found when typing ls is a good way to remind yourself that you are not the system you are used too, and that you should be little more careful (permissions, executable order, and all those lovely inconcistencies). - voyager
13
[+4] [2009-09-02 01:50:06] vraiment

I always liked:

alias h='history'
alias g='grep'
alias hg='h|g'

hg foo now gets your foo history, quick smart.

s'pose you could do:

alias hg='history|grep'

but you lose the (sometimes useful) independent h and g.

-r


I prefer alias h='history' alias g='grep' alias ?='h|g' - James Deville
14
[+4] [2009-08-18 20:27:58] notzach

These are just a few that I use.

alias canhaz='sudo apt-get install'
alias webshare='python -c "import SimpleHTTPServer;SimpleHTTPServer.test()"'
alias fail='kill'
alias sls='screen -ls'
alias rtfm='man'

(8) rtfm is definitely entertaining, but useful??? - Babu
You can also use python -m SimpleHTTPServer for webshare. - Mark Szymanski
15
[+3] [2009-08-19 22:48:30] Benjamin Dobson

For safety, given how little time I tend to spend in the Terminal:

alias rm='rm -i'

Because it makes me smile:

alias please=''

For convenience:

alias launch="osascript /Users/Shared/Scripts/launch.applescript"

what actualy is "$@"? - Igoru
Completely useless. Deleting. - Benjamin Dobson
(14) aliasing rm to rm -i is a bad idea, and generally not recommended. Because you train yourslef to rely on it. Better to alias something different like 'del', so when you use a machine where your aliases don't work, your finger training makes you look silly, not like a moron who just deleted "*" from some directory. - Peter
I like that suggestion. I'll do it. Thanks :) - Benjamin Dobson
@Peter: that's not a bad point. i've had this alias for a little while, but removing it now.. - sml
16
[+3] [2009-09-17 17:14:08] joh6nn

do shell functions count?

mdcd() {
    mkdir -p "$@" && cd "$@"
}

rmalias() {
    unalias $1 && sed -i "/alias $1\=/d" ${HOME}/path/to/aliases
}

mkalias() {
    echo -e "\n# added `date "+%F %T"`" >>  ${HOME}/path/to/aliases
    echo "alias $@" >> ${HOME}/path/to/aliases
    alias $@
}

17
[+3] [2009-08-05 18:46:12] legoscia
alias open="emacsclient -n"

If you'd rather edit everything in Emacs :) Customize server-mode in Emacs to make this work.


I used to do this until I switched to a mac. /usr/bin/open is a super useful command in OS X (it mimics a double-click in the Finder -- similar to cygstart in cygwin). For emacsclient, my alias is now "em" - Doug Harris
18
[+3] [2009-08-05 15:15:49] Jonik

If you use the cal command, and hail from elsewhere than Australia, Canada, New Zealand, UK or USA [1] (or other places with the funny idea that a week begins on Sunday... :-), you might like this:

alias cal='cal -m'

Where -m means:

-m Print a calendar where Monday is the first day of the week, as opposed to Sunday.

Update: As Daniel pointed out in comments, you're probably better off with this:

alias cal='ncal -b'
[1] http://en.wikipedia.org/wiki/Seven-day_week#Week_number

(1) I use alias cal='ncal -b' since I got tired of cal's buggy behaviour related to locales, among other things. - Daniel Andersson
@Daniel, thanks! cal -m no longer works (on recent Ubuntu versions), but ncal -b does the job. - Jonik
19
[+2] [2009-07-17 14:28:41] innaM
alias lt='ls -lrt'

(Btw: For exit, I simply type ctrl-d)


20
[+2] [2009-10-22 19:06:32] community_owned
alias latest='ls -Strr --group-directories-first --color=auto  | tail'

// start, stop, restart, reload daemons in Arch Linux

usage: start <daemon-name>
start()
{
  for arg in $*; do
    sudo /etc/rc.d/$arg start
  done
}
stop()
{
  for arg in $*; do
    sudo /etc/rc.d/$arg stop
  done
}
restart()
{
  for arg in $*; do
    sudo /etc/rc.d/$arg restart
  done
}
reload()
{
  for arg in $*; do
    sudo /etc/rc.d/$arg reload
  done
}

The same should work for anything with a BSD init system - the only other system I know of that uses it (other than *BSD) is Slackware and its derivatives. - new123456
21
[+2] [2010-09-30 10:16:52] ultrasawblade
alias reboot='/usr/local/bin/sobriety-check reboot'
alias poweroff='/usr/local/bin/sobriety-check poweroff'

The above aliases reference scripts I've written that do a uname -a, sleep 10, and then ask me to enter a sentence to confirm the reboot or poweroff.


22
[+2] [2011-07-26 20:13:34] FarmBoy

For navigating deep directory trees:

alias ..='cd ..'
alias ..2='cd ../..'
alias ..3='cd ../../..'
alias ..4='cd ../../../..'
alias ..5='cd ../../../../..'
alias ..6='cd ../../../../../..'
alias ..7='cd ../../../../../../..'
alias ..8='cd ../../../../../../../..'
alias ..9='cd ../../../../../../../../..'

23
[+1] [2010-09-29 12:29:18] Dan
alias ld='ls -l | grep ^d'

List just directories.


24
[+1] [2010-09-29 14:41:44] dtlussier

A couple of my favourites:

Getting the size of the current directory:

alias du-dir='du -h -d 1'  (on OS X)
alias du-dir='du -h --max-depth=1'  (on Linux)

Quickly logging into servers I use a lot:

alias server-name='ssh remote-id@remote.com'

On the Mac another really great one is automating the open command for items you need a lot. The open command asks the system to open the file indicated as if you double clicked on it from the GUI. For example, to get the Activity Monitor from the command line you can do:

alias activity='open /Applications/Utilities/Activity\ Monitor.app/'

A similar idea could be used for other apps, or regularly needed files. Very handy!


25
[+1] [2010-12-07 03:23:13] asoundmove

I like those:

alias push='pushd .'
alias pus=push
alias pu=push
alias p=push
alias pop=popd
alias po=popd

alias sp='source ~/.profile'
alias sb='source ~/.bashrc'
alias gp='gvim ~/.profile'
alias gb='gvim ~/.bashrc'

alias tbz='tar --use-compress-program=bzip2'
alias nn='netstat -r ; netstat -e ; netstat -a'

alias no='yes | sed "y/y/n/"'
alias h=history

26
[+1] [2009-11-14 22:45:45] qedi

To make sure you're in the canonical path for whatever directory you're in. Useful whenever you're using symlinks.

alias "cwd"='cd `pwd -P`; pwd

27
[+1] [2009-09-24 17:06:13] Hai Vu

This is not an alias, but works the same way:

function cd() { builtin cd "${@:-$HOME}" && ls; }

This function redefined the cd command to 1) cd, then 2) list files. Normally, I issue an ls command immediately after the cd command, so this function naturally combine both.


28
[+1] [2009-09-24 17:32:12] tj111

I like to browse through bash like I would with any GUI file-manager, so I use terms that seem more natural to me.

alias go='pushd'
alias back='popd'
alias up='cd ..'

29
[+1] [2009-09-17 17:52:01] grawity
spawn() {
    ( "$@" & ) &> /dev/null
}

Very useful for launching graphical apps. (The braces work kind of like nohup or disown.)


30
[+1] [2009-08-13 21:41:13] ahockley

Because it annoys me that (AFAIK) it's the one command with a longer name in *nix than in Windows:

alias tracert='traceroute'

(3) alias cls=clear anyone? - MiffTheFox
Ah, good catch. I guess tracert isn't the only one. - ahockley
(3) @MiffTheFox I use Ctrl+l for this, never the clear command - Pascal Thivent
31
[+1] [2009-09-03 23:17:19] Peter

I never (anymore) overload standard names with aliases which have different default behavior - like "rm" to "rm -i", because I've trained myself to rely on it in the past, and boy did I make some stuff ups.

No more, train those fingers to use standard commands. But when the standard version of the command is a lightweight, then I can replace it, like my very favorite which replacement.

Not an alias, but bash functions are very similar in power to csh aliases. Bash aliases don't cut the mustard for lots of stuff.

(Edit, rwhich is a "real which, which is part of which infrastructure I left out before.)

if alias which 2>/dev/null 1>&2 ; then unalias which; fi
unset which
alias rwhich="`which which`"
function which ()
{
    if [ x"$1" == x ] ; then
        echo "Usage: which command" 1>&2
        return 1
    fi
    # @todo Fix this so it doesn't require executing the command twice.
    # Using /dev/tty as the redirection for stdout causes problems for
    # redirecting the function. :-(
    (alias ; declare -f)  | \
        rwhich --tty-only --read-function --read-alias --show-dot \
               --show-tilde "$@" 2>/dev/null
    local fn_errors="`(alias ; declare -f)  | \
        rwhich --tty-only --read-function --read-alias --show-dot \
               --show-tilde \"$@\" 2>&1 1>/dev/null`"
    local help_result="`help ${!#} 2>&1 | head -1 | cut -d\: -f1`"
    if [ "x%" == "x${!#}" ] ; then
        #Special case. Bah.
        if [ -n "$fn_errors" ] ; then
            echo $fn_errors 1>&2;
            return 1
        fi
    elif [ "x$help_result" == "x${!#}" ] ; then
        echo ${!#} is a bash builtin
    elif [ "x[[" == "x${!#}" ] ; then
        #Special case. Bah.
        echo ${!#} is a bash builtin
    elif [ "x((" == "x${!#}" ] ; then
        #Special case. Bah.
        echo ${!#} is a bash builtin
    elif [ "x:" == "x${!#}" ] ; then
        #Special case. Bah.
        echo ${!#} is a bash builtin
    elif [ -n "$fn_errors" ] ; then
        echo $fn_errors 1>&2;
        return 1
    fi
}

32
[+1] [2009-08-20 01:39:08] Igoru

I usually have:
+ grep='grep -irn --color' => coloring, case-insensitive, recursive and shows line number
+ ls='ls -lGh --color --time-style="+%T %d/%m/%Y"' => long list, doesn't show groups, show human-readable sizes, coloring, and changes time style for brazilian way

I also uses an alias for each database connection I have.
At work i have three: development, testing and production; so I have those aliases: pg-d, pg-t, and pg-p that calls psql in an specific host, with user, asking for password.
At home i make freelances, so I have aliases like sabia that does mysql -u sabia -p, for example.


33
[+1] [2009-07-17 14:04:13] Lasse V. Karlsen

Mine, on Windows:

Also, I use Take Command [2] as a replacement for CMD.

[1] http://www.flos-freeware.ch/notepad2.html
[2] http://www.jpsoft.com/tcmddes.htm

finally another soul using TakeCommand! :-) - marc_s
Why "e" ? Why not "n" if you're using Notepad2 ? (cause e is the name of another text editor) ... - ldigas
34
[+1] [2009-08-05 15:25:10] bedwyr

Here are a few I've found useful depending on the environment:

alias ssh='ssh -X' # export DISPLAY to this Xserver
alias rm='rm -i'   # make sure I want to delete
alias pgr='pgrep'
alias pk='pkill'
alias more='less'  # a MUST because I type 'more' without thinking
alias vi='vim'     # only works in certain instances

(1) For ssh, I'd suggest editing ~/.ssh/config, so you can still disable X tunneling for really slow (e.g. inter-planetary, or via 1+ satellite(s)) connections. - mctylr
35
[0] [2009-07-17 14:25:40] chaos
s1 = screen -dRRS chaos1
s2 = screen -dRRS chaos2
s3 = screen -dRRS chaos3
s4 = screen -dRRS chaos4
s5 = screen -dRRS chaos5
s6 = screen -dRRS chaos6

What's going on here? Do each of the different screen sessions connect to different machines? Why not have one screen session with multiple windows? - Doug Harris
Each one's a tab in my terminal client. I don't care to use screen's window management. - chaos
36
[0] [2009-08-05 13:05:30] Adam Matan
alias wsplit='xrandr --output LVDS --pos 0x880'

Used when my laptop is connected to another screen - splits the virtual screen and gives me another workspace for free.


37
[0] [2009-08-28 18:30:06] secureBadshah

I use the following alias for quickly checking out the changed files in a directory with CVS server:

alias changes='cvs stat | grep Status | grep Up-to-date'

38
[0] [2009-09-03 12:36:15] Peter Eisentraut

If you are using zsh, I recommend these:

alias -g L="| less"
alias -g S="| sort"

They allow you to do quickly add "less" or "sort" to the end of everything without cumbersome typing, e.g.:

diff -ur foo/ bar/ L

If you are not using zsh, you shouldn't be asking about shell customization. :-)

If you are using zsh, you shouldn't be asking about aliases, but about shell functions. :-)


39
[0] [2009-08-13 20:21:19] Joey

Sometimes Ctrl+D comes in handy to close a session, but it can't be used directly in Powershell. So I created a function that solves this:

iex "function $([char]4) { exit }"

Then Ctrl+D, Enter closes the shell. Not quite right, but close.


40
[0] [2009-09-17 18:32:01] akira

shortcut for sudo plus setting variables in the context of the new process

+() { sudo env "$@" }

41
[0] [2009-11-05 03:46:59] Lokal

Not an alias, but lives in my bashrc:

export CDPATH='/path/on/this/machine/'

The CDPATH environment variable defines additional locations to be searched when you type the cd command.


42
[0] [2009-11-15 00:13:10] JustJeff
alias up='cd ..'

I use alias ..='cd ..' - Mark Szymanski
43
[0] [2009-11-15 03:18:07] xenoterracide
alias ls="ls --color"
alias ll="ls -l --color --human-readable"
alias la="ls -l --color --all"
alias df="df -h"
alias du="du -h"
alias locate="locate -i"
alias info="info --vi-keys"
alias ssr="ssh -l root"
#alias less="/usr/share/vim/vim71/macros/less.sh"
alias diff="diff -u"
alias vi="vim -Xp"
alias vim="vim -Xp"

44
[0] [2010-01-08 09:02:58] Alok

I had posted this [1] on stackoverflow in response to the question: Hidden features of bash, but it's relevant here too.

I have an alias r='fc-s', and I find it very useful in some limited cases. To run the last command, just type r and hit enter, and that's it. Of course, that itself is not very useful because up arrow does the same thing. But you can use r to run the previous command with substitutions. Let's say your last command was a long command compiling some file:

$ gcc -c <file_name>.c <lots of options> -o <file_name>.o

Now you want to compile another file with the same options and have a corresponding .o file:

$ r <file_name>=<new_file>

will do it. You don't have to use up arrow, navigate to the right places and then replace them each manually. This can be repeated multiple times, so you can do this next:

$ r <new_file>=<other_file>

Of course, for such a thing you have makefiles, but I hope I have shown that the alias is useful.

I haven't needed the use of this alias a lot, but there have been times that I have been glad that I have this alias!

[1] http://stackoverflow.com/questions/211378/hidden-features-of-bash/1881903#1881903

45
[0] [2010-01-17 06:48:06] klingonesque
less='less -r'

Displays raw characters, which, among other things, retains color of the text.


Alternately, you could set the LESS environment to r and that would be used automatically every time less is called, not just when you type it on the command line (e.g. when you're viewing man pages). I have export LESS='icM' in my .bashrc. - Doug Harris
46
[0] [2010-03-08 18:11:54] community_owned

Mine are:

# too lazy :)
alias ..='cd ..'
# remove those pesky .DS_Store OSX files recursively
alias cleandsstore='find . -name ".DS_Store" -type f -print0 | xargs -0 rm -f'
# remove all .svn directories recursively (careful!)
alias cleansvn='find . -type d -name .svn -depth -exec rm -rf {} \;'
# chmod files to 0644 and directories to 0755 recursively
alias fixperm='find $PWD -type f -print0 | xargs -0 chmod 0644 && find $PWD -type d -print0 | xargs -0 chmod 0755'
# remove empty lines and lines beginning with # (usually comments) from stdin, useful to slim down config files
alias stripcomment='sed -e '\''/^\#/d'\'' -e '\''/^$/d'\'''

Cheers ;)


47
[0] [2010-03-24 14:07:41] Benjamin Delichère

on linux (debian-like) :

huge time savers

alias search="apt-cache search"
alias install="sudo apt-get install"
alias show="apt-cache show"

digging installed package list

alias dgrep="dpkg -l |grep"

ssh to home server (with public key authentication)

alias sshome="ssh -l MY_HOME_USER MY_HOME_IP -p MY_HOME_SSH_EXTERNAL_PORT $*"

character encoding converters

alias utf2iso="iconv -c --from-code=UTF-8 --to-code=ISO-8859-15"
alias iso2utf="iconv -c --to-code=UTF-8 --from-code=ISO-8859-15"

usage : utf2iso utf_file > iso_file

48
[0] [2010-05-14 16:47:16] Dlf
c = 'clear
l = 'ls -Filah'
ggg = 'newgrp <GROUP_NAME>'
xxx = 'xterm -sb -sl 10000 -fg green1 -bg DarkSlateGrey -geometry 65x40 -cr green2'

49
[0] [2010-12-07 07:56:08] Ryan Thompson

I've posted this in other "favorite aliases" threads, and it's always controversial, but I stand by it:

sudo apt-get install trash-cli
alias rm=trash

If you're not using Debian, it might actually be alias rm=trash-put instead.

Now when you "delete" things on the command line, they show up in your trash can.


50
[0] [2011-06-18 02:04:49] hced

To edit a file (assuming you have set your $EDITOR environment variable):

alias e="$EDITOR"

51
[0] [2011-06-20 19:46:22] jpaugh

My days working under MS-DOS spoiled me. I can't live without this one.

cls=tput\ reset

52
[0] [2011-07-15 15:08:35] Vaibhav Bajpai

I prefer tree over ls

alias t="tree -LFC 1 --dirsfirst"

function te(){
 tree -LFC $1 --dirsfirst $2
} 

53
[0] [2011-07-26 19:52:50] jankes

alias hrr='history -c; history -r'

Useful when I experiment a lot with something on the command line, but don't want all that garbage to make it to the .bash_history file.


54
[0] [2010-09-30 11:57:50] jokester

Maybe it's silly, but this was useful for a Linux programmer working in a Windows-based company:

pp () { getclip |eval "$@" |putclip }  #sed or do sth with clipboard's content.

g { grep \`getclip` $1 $2 $3 * -R }

55