Home
Über die LugBE | Mailing List | Treff & Events | Projekte | lost+found | Support

Shell Aliases & Shortcuts

Auf jeder Shell nützlich für den täglichen Gebrauch: Aliases. Wer tippt sich schon gern die Finger mit den ewig gleichen Kommandos wund ;-)
Dienstbar macht man sich die Geister, indem man sich ein File mit Aliases, Funktionen usw. anlegt und dieses dann beim Einloggen (oder von Hand) von seiner Shell einlesen lässt. (man source) Dazu eignet sich bei der Bash /etc/profile (systemweit) oder ~/.bashrc und ~/.profile. Es kann aber auch jedes andere File sein, das von irgendwoher während des Login-Prozesses gesourced wird.
Hier ein paar Anregungen:

# # Aliases
#
# clear screen
alias c='clear'

# command history
alias h='history'

# background jobs
alias j='jobs -l'

# und tschüss
alias lo='logout'

# net stats
alias nett='netstat -t'

# pager
alias p=$PAGER

# now vim
alias vi='vim'


# deb info
alias di='dpkg-deb -I'

# deb install
alias din='dpkg -i'

# give me music, baby
alias alr='aumix -L'

# plan the next step
alias plan='vi +3 ~/.plan'

# split terminal and login ^W to switch. great.
alias st='splitvt -login'

# next module
alias miknext='killall -USR1 mikmod'

# amp full power
alias amp='amp -volume 100'

# give me my spoolit, slrn.
alias slrn='slrn --spool'

#
#Searching for "mutt", max. output is 5 ... 13 matches found.
#mutt der Dussel
#mutt der Köter
#mutton der Hammel
#mutton das Hammelfleisch
#muttered gemurmelt
alias m='mutt'

# 's slrn
alias s='slrn'

#
# fs movement
#

# give me options, baby
alias ls="ls $LS_OPTIONS"

# *argh* dos lusers...
alias dir="dir $LS_OPTIONS"

# nah. sorry. this is stupid. luser backward compatibility
alias vdir="vdir $LS_OPTIONS"

# yeah, dirty dir. move on. speed on.
alias d="dir"

# long, long
alias v="vdir"

# dot files
alias dot="ls -d .*"

# push it
alias pu='pushd'

# pop it
alias po='popd'

# one step back, please
alias cd..='cd ..'

# step by step
alias cdd='cd ..; ls'

#
# Functions
#

# smash the door and step in
cdl () { cd "$1"; d; }

# smash the door, step in and scan it
cdv () { cd $1; v; }

# internalnote: don't forget to strip
mcdm () { mount /cdrom && cd /cdrom && ls; }

# i want it back
ucde () { umount /cdrom && eject; }

# psst
pss () { ps aux -O$1 | p; }

# deb list package files and page
dl () { dpkg -L $1 | p; }

# deb status
ds () { dpkg -s $1 | p; }

# "yeah handy"-collection: give stats, give me list
dsl () { ds $1 ; dl $1; }

# i'm the timekiller
aplan () { if [ $# = 1 ]; then echo - $1 >>~/.plan; fi; }

# no remorse
vplan () { cat ~/.plan; }

# ftp search
ftps () { lynx http://ftpsearch.lycos.com/cgi-bin/search?query="$1"; }

# midnight command by douse
mc () { MC=`/usr/bin/mc -P -d "$@"`; [ -n "$MC" ] && cd "$MC"; unset MC ; }

# last but not least: -=-[psgrep]-=- *blinkenlights* (see jargon)
# process list report filtered by egrep
psgrep() { ps auxw | egrep "^USER|$1" | grep -v grep ; }

# :wq


Und noch ein paar Beispiele aus /etc/profile

# set up the color-ls environment variables:
if [ "$SHELL" = "/bin/zsh" ]; then
eval `dircolors -z` ;
elif [ "$SHELL" = "/bin/ash" ]; then
eval `dircolors -s` ;
else
eval `dircolors -b /etc/DIR_COLORS` ;
fi

# check for new files

# Notify user of incoming mail. This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
biff y

# Shell modifiers
set -b # print term. jobs message immediately
ulimit -S -c 0 # set soft core dump size to 0
umask 022 # default file creation mask
export ignoreeof=10 # don't exit shell on EOF
shopt -s cdspell # auto-correct spelling errors with cd

# Execute other commands
source /usr/local/etc/profile.cmds

# To be run by the PROMPT_COMMAND variable, so that one can see what
# the exit status of processes are.

function check_exit_status ()
{
local status="$?"
local signal=""

if [ ${status} -ne 0 -a ${status} != 128 ]; then
# If process exited by a signal, determine name of signal.
if [ ${status} -gt 128 ]; then
signal="$(builtin kill -l $((${status} - 128)) 2>/dev/null)"
if [ "$signal" ]; then signal="($signal)"; fi
fi
echo "[Exit ${status} ${signal}]" 1>&2
fi
return 0
}
export PROMPT_COMMAND=check_exit_status

# 8-bit operation, erase character BackSpace,
# C-x sends SIGQUIT and remap non-working ^\
stty pass8 erase ?

# system news
/usr/bin/news -p

echo Plan:
cat $HOME/.plan
echo

# To be run by the PROMPT_COMMAND variable, so that one can see what
# the exit status of processes are.

function check_exit_status ()
{
local status="$?"
local signal=""

if [ ${status} -ne 0 -a ${status} != 128 ]; then
# If process exited by a signal, determine name of signal.
if [ ${status} -gt 128 ]; then
signal="$(builtin kill -l $((${status} - 128)) 2>/dev/null)"
if [ "$signal" ]; then signal="($signal)"; fi
fi
echo "[Exit ${status} ${signal}]" 1>&2
fi
return 0
}
export PROMPT_COMMAND=check_exit_status

Nach oben


Webmaster at lugbe.ch

Die Artikel dieser Seite stehen unter Copyleft ihrer jeweiligen Autoren. Ihre Nutzung, Wiedergabe etc. untersteht den Bedingungen der GNU Free Documentation License (http://www.gnu.org/copyleft/fdl.html), wo nicht explizit anders vermerkt.