View previous topic :: View next topic |
Author |
Message |
neenee Veteran
Joined: 20 Jul 2003 Posts: 1786
|
Posted: Wed Jan 28, 2004 12:52 pm Post subject: show me your aliases |
|
|
apologies if this is a duplicate - i did search the forums
before i posted.
since i was pondering on the possible uses of aliases,
i thought a thread on this, where people share their
aliases, would be a useful thing.
to start this off, here are mine:
Code: | alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias ls='ls --color=auto'
alias lx='ls --color=auto -Fs'
alias lh='ls --color=auto -Fsh'
alias free='freecolor -m'
alias root='sudo /bin/bash --login'
alias blank='echo < /dev/null >'
alias grep='grep --colour=auto'
|
|
|
Back to top |
|
|
Oyarsa n00b
Joined: 01 Jul 2002 Posts: 73 Location: Mars
|
Posted: Wed Jan 28, 2004 3:21 pm Post subject: |
|
|
Is this the kind of stuff you mean?
Quote: | alias h=history
alias up='cd ..'
alias del='rm -i'
alias la='ls -a'
alias lst='ls -l'
alias dir='pwd; ls; ls | wc -w' # VAX style listing
# show size of subdirectories in K
alias csize='du -k | sort -r -n | more'
# a sort of recursive grep
alias rgrep='find . -name "*" | xargs grep '
# For old time Adventure fans
alias xyzzy='echo Nothing Happens'
alias plugh="echo That Doesn\'t Work Here" |
_________________ Dew knot trussed yore spell chequer two fined awl ewer miss steaks. |
|
Back to top |
|
|
Aurora l33t
Joined: 26 Sep 2003 Posts: 658 Location: Classified
|
Posted: Wed Jan 28, 2004 3:25 pm Post subject: |
|
|
This should be a helpful thread in terms of getting ideas for my own alias file.
Out of curiosity (and I did man ls), why do you have lx having only the -Fs arguments, and lh having -Fsh
i.e., what good is it to only have -Fs as opposed to -Fsh?
Great thread, btw... _________________ "My downfall raises me to infinite heights." -Napoleon Bonaparte |
|
Back to top |
|
|
mlsfit138 Guru
Joined: 20 Sep 2003 Posts: 406 Location: Washington
|
Posted: Wed Jan 28, 2004 4:16 pm Post subject: |
|
|
Yeah, I think this could be an interesting thread. Maybe it would be better placed in Tips & Tricks though? _________________ "Everytime you justify
another good in you dies"
-Converge, The Saddest Day, Petitioning the Empty Sky |
|
Back to top |
|
|
asimon l33t
Joined: 27 Jun 2002 Posts: 979 Location: Germany, Old Europe
|
Posted: Wed Jan 28, 2004 4:26 pm Post subject: |
|
|
I very much like the following aliases which I haven't seen here yet:
Code: | alias ..='cd ..'
alias ...='cd ../..'
which emacs &>/dev/null && alias e='emacs'
|
|
|
Back to top |
|
|
bigcat99 n00b
Joined: 06 Jan 2004 Posts: 45 Location: Boston
|
Posted: Wed Jan 28, 2004 4:29 pm Post subject: |
|
|
where to i define aliases?
Last edited by bigcat99 on Wed Jan 28, 2004 4:44 pm; edited 1 time in total |
|
Back to top |
|
|
ronmon Veteran
Joined: 15 Apr 2002 Posts: 1043 Location: Key West, FL
|
Posted: Wed Jan 28, 2004 4:32 pm Post subject: |
|
|
Being basically lazy , I'm a fan of aliases. Arguably, there is some psychological influence in my choice of spam filter related aliases. From my user .bashrc:
Code: |
alias bs='bogolearn.sh'
alias la='ls -a'
alias ll='ls -al'
alias lr='ls -LR'
alias ls='ls --color'
alias mx2='mogrify -resize 200%x200%'
alias mx15='mogrify -resize 150%x150%'
alias mx17='mogrify -resize 175%x175%'
alias tug='tar zxvf'
alias tub='tar jxvf'
alias tcg='tar czf'
alias tcb='tar cjf'
alias mf='mailfilter'
alias ntn='nano ~/depot/hardware/track_nos'
alias g='wget'
|
And the ones from root that don't overlap:
Code: |
alias fnc='find /etc -iname '._cfg????*''
alias bk='make -j4 bzImage && make -j4 modules && make modules_install'
|
The entire files (and a few others) are listed here.
Oyarsa, I like your 'up' alias. I'll be adding that one to my list. |
|
Back to top |
|
|
mlsfit138 Guru
Joined: 20 Sep 2003 Posts: 406 Location: Washington
|
Posted: Wed Jan 28, 2004 4:44 pm Post subject: |
|
|
bigcat99 wrote: | where to i define aliases? |
you define aliases in ~/.bashrc. There are already a few aliases in there by default, so you can just add these to the list _________________ "Everytime you justify
another good in you dies"
-Converge, The Saddest Day, Petitioning the Empty Sky |
|
Back to top |
|
|
puddleglum n00b
Joined: 04 Jul 2002 Posts: 63 Location: Albuquerque
|
Posted: Wed Jan 28, 2004 5:01 pm Post subject: |
|
|
# list only directories
Code: | lsd lsd='ls -F | ls -d */' |
# list only source code (c, c++, Perl in my case)
Code: | lsp='ls *.c *.h *.cc *.pl *.pm' |
functions used as aliases
# decimal to hex
Code: | function d2h { echo 16o $1 p | dc } |
# hex to decimal
Code: | function h2d { echo $1 | tr '[a-f]' '[A-F]' | xargs -i echo 16i {} p | dc } |
# negative to hex
Code: | function n2h { echo 16o 0 0 $1 sa1 '[16*dla>y]sy' lyx '16*la' -p | dc } |
# hex to negative
Code: | function h2n { echo $1 | tr '[a-f]' '[A-F]' | xargs -i echo 16i {} dsa1 '[10*dla>y]sy' lyx -p | dc } |
_________________ Disregard everything below the line. |
|
Back to top |
|
|
asimon l33t
Joined: 27 Jun 2002 Posts: 979 Location: Germany, Old Europe
|
Posted: Wed Jan 28, 2004 5:46 pm Post subject: |
|
|
Here is an other one for fast switching between source dir and build dir. kdecvs is the base under which the source dirs reside (i.e. kdecvs/kdebase) and kdecvs/build contains the build dirs named after the source dirs (i.e. kdecvs/build/kdebase). I have this alias since ages in my bashrc, it's from an KDE developer whose name I have forgotten (shame on me!):
Code: | alias cb='cd `pwd | sed -e 's,kdecvs,kdecvs/build,'`'
alias cs='cd `pwd | sed -e 's,kdecvs/build,kdecvs,'`'
|
|
|
Back to top |
|
|
squiddy n00b
Joined: 31 Mar 2003 Posts: 39 Location: Colorado, USA
|
Posted: Wed Jan 28, 2004 5:48 pm Post subject: |
|
|
Here are a few I commonly use (tcsh syntax):
Code: | alias forest 'ps -e --forest'
alias from 'grep '^From:' $MAIL'
# super-lp for duplex, 2 per side printing, with multiple files
alias slp 'a2ps -2rjA -s2 --medium=Letter'
alias rmtmp 'rm *~ #*#'
alias qfind 'find . -name'
# get info about latest kernel releases
alias kernelinfo 'finger @kernel.org'
alias mkthumb 'convert -resize 5%' |
Last edited by squiddy on Wed Jan 28, 2004 6:29 pm; edited 1 time in total |
|
Back to top |
|
|
asimon l33t
Joined: 27 Jun 2002 Posts: 979 Location: Germany, Old Europe
|
Posted: Wed Jan 28, 2004 5:52 pm Post subject: |
|
|
puddleglum wrote: |
Code: | function d2h { echo 16o $1 p | dc }
function h2d { echo $1 | tr '[a-f]' '[A-F]' | xargs -i echo 16i {} p | dc }
function n2h { echo 16o 0 0 $1 sa1 '[16*dla>y]sy' lyx '16*la' -p | dc }
function h2n { echo $1 | tr '[a-f]' '[A-F]' | xargs -i echo 16i {} dsa1 '[10*dla>y]sy' lyx -p | dc } |
|
This is no bash syntax, isn't it?
The manual says [ function ] name () { list; } |
|
Back to top |
|
|
PrakashP Veteran
Joined: 27 Oct 2003 Posts: 1249 Location: C.C.A.A., Germania
|
Posted: Wed Jan 28, 2004 5:59 pm Post subject: |
|
|
Nice thread, already added some.
Here are some of mine:
Code: |
alias d="ls --color -h"
alias ls="ls --color=auto -h"
alias ll="ls --color -lh"
alias na="nano -w"
alias epw="emerge -uDpv world"
alias ew="emerge -uD world"
alias es="emerge sync"
alias kinst="mount /boot && cp arch/i386/boot/bzImage /boot/bzImage && umount /boot"
alias cdk="cd /usr/src/linux"
|
|
|
Back to top |
|
|
Birnenpfluecker Guru
Joined: 01 Sep 2003 Posts: 315 Location: Lage, Germany
|
Posted: Wed Jan 28, 2004 6:01 pm Post subject: |
|
|
Here are mine:
Quote: |
alias d="ls --color"
10 alias ls="ls --color=auto"
11 alias ll="ls --color -l"
12 alias md='mkdir'
13 alias rd='rmdir'
14 alias h='history'
15 alias es='emerge -s'
16 alias ep='emerge -p'
17 alias merge='ACCEPT_KEYWORDS="~x86" emerge'
18 alias uw="emerge -UD world"
19 alias up="emerge -pUD world"
20 alias mp="mplayer" |
|
|
Back to top |
|
|
sigix Apprentice
Joined: 25 Jul 2003 Posts: 192
|
Posted: Wed Jan 28, 2004 7:11 pm Post subject: |
|
|
Code: |
alias rm='rm -i'
alias cp='cp -i'
alias ls='ls --color=auto'
alias mv='mv -i'
alias c='cd /mnt/c'
alias d='cd /mnt/d'
alias e='cd /mnt/e'
alias mf='mount /dev/fd0 /mnt/floppy'
alias uf='umount /mnt/floppy'
alias gf='cd /mnt/floppy'
alias www='ping 192.168.0.1'
alias gens='cd /var/www/html/gen'
alias connect='ssh -l kb 192.168.0.111'
alias web='cd /var/www/html'
alias off='init 0'
alias sweb='service httpd start;service mysqld start'
alias eweb='service httpd stop;service mysqld stop'
|
|
|
Back to top |
|
|
m@o Apprentice
Joined: 25 Nov 2003 Posts: 184 Location: /eu/at/grz
|
Posted: Wed Jan 28, 2004 7:36 pm Post subject: |
|
|
Code: | alias d="ls --color"
alias ls="ls --color=auto"
alias ll="ls --color -l"
alias lh="ls --color -lh"
alias mdvd="mount /mnt/cdrom1"
alias mcd="mount /mnt/cdrom2"
alias fbird="MozillaFirebird"
alias tbird="MozillaThunderbird" |
|
|
Back to top |
|
|
puddleglum n00b
Joined: 04 Jul 2002 Posts: 63 Location: Albuquerque
|
Posted: Wed Jan 28, 2004 7:55 pm Post subject: |
|
|
Quote: | asimon wrote:
Quote: | puddleglum wrote:
Code:
function d2h { echo 16o $1 p | dc }
function h2d { echo $1 | tr '[a-f]' '[A-F]' | xargs -i echo 16i {} p | dc }
function n2h { echo 16o 0 0 $1 sa1 '[16*dla>y]sy' lyx '16*la' -p | dc }
function h2n { echo $1 | tr '[a-f]' '[A-F]' | xargs -i echo 16i {} dsa1 '[10*dla>y]sy' lyx -p | dc } |
This is no bash syntax, isn't it?
The manual says [ function ] name () { list; } |
You are probably right. These are bourne shell scripts which should
work in bash. They did for me here with bash-2.05a. I did have to
convert them, though since we use the csh shell at work. I'll check
when I get home what my linux box has in it.
It seams like I did get sloppy, though. My first two examples are
incorrect. They should be:
Code: | alias lsd='ls -F | ls -d */'
alias lsp='ls *.c *.h *.cc *.pl *.pm'
|
_________________ Disregard everything below the line. |
|
Back to top |
|
|
elzbal Guru
Joined: 31 Aug 2002 Posts: 364 Location: Seattle, WA, USA
|
Posted: Wed Jan 28, 2004 7:56 pm Post subject: |
|
|
Here's mine:
As you can see, I like typing.
On a personal note, I *hate* the "rm -i", "mv -i", etc aliases. As an old-time Unix user, I don't like the silly "are you sure" messages. If I tell you to rm -r /, then I want you to do it. |
|
Back to top |
|
|
joehni Apprentice
Joined: 27 Jul 2003 Posts: 175
|
Posted: Wed Jan 28, 2004 8:59 pm Post subject: |
|
|
elzbal wrote: | On a personal note, I *hate* the "rm -i", "mv -i", etc aliases. As an old-time Unix user, I don't like the silly "are you sure" messages. If I tell you to rm -r /, then I want you to do it. |
Well, you can secure yourself selectivly. I have at least saved my root and home:
Well, here some lines from my .bashrc, comes in handy when developing Java:
Code: |
function ..()
{
local i;
local p;
if [ $# == 0 ]; then
cd ..;
else
i=$1
p="."
while [ $i -gt 0 ]; do
p=$p/..
i=$((i-1))
done
cd $p
fi
}
|
|
|
Back to top |
|
|
ecatmur Advocate
Joined: 20 Oct 2003 Posts: 3595 Location: Edinburgh
|
Posted: Wed Jan 28, 2004 9:04 pm Post subject: |
|
|
mm, fun: Code: | alias anagrams='/bin/gawk '\''BEGIN { s=ARGV[1]; ARGV[1]=""; for (i=2; i<ARGC; ++i) { s=(s ARGV[i]); ARGV[i]="" }; target="^" tolower(sort(s)) "$" }; function sort(s) {ret=""; split(s, a, ""); n=asort(a); for (i=1; i<=n; ++i) if (a[i] ~ /[[:alnum:]]/) ret = (ret a[i]); return ret }; tolower(sort($0)) ~ target { print };'\'''
alias aspell='/usr/bin/aspell -d en.multi'
alias d='ls --color'
alias ginfo='gviminfo'
alias gman='/usr/bin/man -P "col -bp | iconv -c | gvim -R -c '\''set ft=man nomod nolist'\'' -"'
alias gview='gvim -R'
alias info='viminfo'
alias ll='ls --color -l'
alias ls='ls -F --color=auto'
alias man='/usr/bin/man -P "col -bp | iconv -c | view -c '\''set ft=man nomod nolist'\'' -"'
function viminfo () { vim -c "Info $1" -c "bdelete 1"; }
function gviminfo () { gvim -c "Info $1" -c "bdelete 1"; } | In case you hadn't guessed... I love vim! |
|
Back to top |
|
|
puddleglum n00b
Joined: 04 Jul 2002 Posts: 63 Location: Albuquerque
|
Posted: Thu Jan 29, 2004 3:43 am Post subject: |
|
|
Quote: | This is no bash syntax, isn't it? |
OK. Here are the versions of decimal/hex conversion from my .bashrc file. This one
accepts any number of entries and gives you a result for each one. One per line.
# Convert decimal to hex
Code: | d2h()
{
for param
do
echo 16o $param p | dc
done
} |
# Convert hex to decimal
Code: | h2d()
{
for param
do
echo $param | tr '[a-f]' '[A-F]' | xargs -i echo 16i {} p | dc
done
} |
# Convert negative decimal to hex
Code: | n2h()
{
for param
do
echo 16o 0 0 $param sa1 '[16*dla>y]sy' lyx '16*la' -p | dc
done
} |
# Convert hex to negative decimal
Code: | h2n()
{
for param
do
echo $param | tr '[a-f]' '[A-F]' | \
xargs -i echo 16i {} dsa1 '[10*dla>y]sy' lyx -p | dc
done
} |
_________________ Disregard everything below the line. |
|
Back to top |
|
|
mlsfit138 Guru
Joined: 20 Sep 2003 Posts: 406 Location: Washington
|
Posted: Thu Jan 29, 2004 6:12 pm Post subject: |
|
|
joehni wrote: | elzbal wrote: | On a personal note, I *hate* the "rm -i", "mv -i", etc aliases. As an old-time Unix user, I don't like the silly "are you sure" messages. If I tell you to rm -r /, then I want you to do it. |
Well, you can secure yourself selectivly. I have at least saved my root and home:
|
what does that do? _________________ "Everytime you justify
another good in you dies"
-Converge, The Saddest Day, Petitioning the Empty Sky |
|
Back to top |
|
|
ragnwald n00b
Joined: 20 Dec 2002 Posts: 43 Location: Stockholm
|
Posted: Thu Jan 29, 2004 7:20 pm Post subject: |
|
|
The only alias i've got is
Code: |
alias pico='nano -w'
|
|
|
Back to top |
|
|
ebrostig Bodhisattva
Joined: 20 Jul 2002 Posts: 3152 Location: Orlando, Fl
|
Posted: Thu Jan 29, 2004 7:27 pm Post subject: |
|
|
First off all, this thread needs to be moved. This is not a question of support. Gentoo Chat would be the correct forum.
When that is said, there was a thread last year about a similar topic, quick console tricks that covers the same topic
Erik _________________ 'Yes, Firefox is indeed greater than women. Can women block pops up for you? No. Can Firefox show you naked women? Yes.' |
|
Back to top |
|
|
dh3rm3 Tux's lil' helper
Joined: 26 Aug 2003 Posts: 101
|
Posted: Thu Jan 29, 2004 7:31 pm Post subject: |
|
|
here are mine
Code: |
alias siteput="sitecopy -uo"
alias siteget="sitecopy -so"
alias d="ls -alh --color"
alias ls="ls --color=auto"
alias ll="ls --color -l"
alias c='clear'
alias df='pydf'
alias make='make $* | grcat conf.gcc'
alias mad='madplay --tty-control -v -r *.mp3'
alias ogg='ogg123 -v *.ogg'
alias cd..='cd ..'
alias merge='ACCEPT_KEYWORDS=~x86 emerge'
alias grep="grep --color=auto"
alias sfv='cksfv -f *.sfv -i'
alias csfv='cksfv * > files.sfv'
alias ipupdate='ez-ipupdate -c ~/bin/ez.conf'
alias materm='multi-aterm'
alias mplayerdvd='mplayer dvd://1 -dvd-device /dev/hdb'
alias mplayervcd='mplayer vcd://1'
alias camrecord='transcode -i /dev/video0 -f 7 -y xvid -g 352x288 -z -x v4l -o file.avi'
alias mc="mc --colors directory=,green,default:executable=,default:link=,default:device=,default:special=,default:normal=,default:selected=red,default:marked=,default:markselect=,blue:core=,default"
|
_________________ dh3rm3's place |
|
Back to top |
|
|
|