Zeigt her eure $SHELLrc!

T

Thorsten Ball

Ich dachte es könnte ganz interessant werden, wenn man einen Thread hat indem man
sich ein paar Tricks, die andere in ihrer RC-Datei haben, abgucken kann. Also dann mal los:

~/.bashrc
Code:
# colors for ls, etc.
eval `dircolors -b /etc/DIR_COLORS`
alias d="ls --color"
alias ls="ls --color=auto"
alias ll="ls --color -l"
alias lh="ls --color=auto -lh"

# You will thank me for this one day.
alias rm="rm -i"

# Biggest file in directory
alias ducks='du -chks * |sort -rn |head -11'

# Nano
alias nano='nano -w'

# Screen
alias screen='screen -R -D'

# Bittorrent
alias bt6='btdownloadcurses.py --max_upload_rate 6'
alias bt12=' btdownloadcurses.py --max_upload_rate 12'

# cplay with random playlist
alias cplay='cplay -R'

# ssh aliases
alias 1='ssh gate.0x42.com'

# Function to search in bash history (thanks to OneOfOne)
hs()
{
    grep --color=auto -irn $*  $HOME/.bash_history
}
# Search for string in files through dirs and subdirs (thanks to darkless)
alias finn='find . | xargs grep -HnI --color=auto'

# Change the window title of X terminals 
case $TERM in
        xterm*|rxvt|Eterm|eterm)
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
                ;;
        screen)
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
                ;;
esac

# Standard
source /etc/profile

# Add my python-scripts to $PATH
export PATH=$PATH:/home/mrnugget/Dev/Python/

# Extended bash-completion
[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion

# Set prompt
export PS1="\[\033[33m\]\t\[\033[01;00;0m\] [\[\033[34m\]\u@\h\[\033[01;00;0m\]][\[\033[32m\]\w\[\033[01;00;0m\]]\$ "

Gruß,
Thorsten
 
Bash-3.0 auf OpenBSD 3.6
Code:
# export... {{{
export LESS="-M"
export PAGER=less
export EDITOR=vim
export CVS_RSH=ssh
export CVSROOT=/var/cvs
export TERM=xterm-color
# }}}
# Aliase {{{
alias ls='/usr/local/bin/gls -lAh --color=always'
alias dig='dig @ns1.teuto.net'
alias ns='netstat -an -f inet'
# }}}
# PATH {{{
PATH="/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin"
# }}}
# Prompt {{{
if [ $EUID -eq 0 ]; then
    PS1='\[\033[01;31m\]\h \[\033[01;34m\]\W \$ \[\033[00m\]'
else
    PS1='\[\033[01;32m\]\u@\h \[\033[01;34m\]\w \$ \[\033[00m\]'
fi
# }}}
# LS_COLORS for gls {{{
export LS_COLORS='*.swp=00;44;37:*,v=5;34;93:*.vim=35:no=0:fi=0:di=32:ln=36:or=1;40:mi=1;40:pi=31:so=33:bd=44;37:cd=44;37:ex=35:*.jpg=1;32:*.jpeg=1;32:*.JPG=1;32:*.gif=1;32:*.png=1
# }}}
# umask {{{
umask 077
# }}}
# Completion {{{
[ -f /etc/bash_completion/bash_completion ] && {
    source /etc/bash_completion/bash_completion
}
# }}}
 
Code:
source /etc/profile
#eval `dircolors -b /etc/DIR_COLORS`
alias d="ls --color"
alias ls="ls --color=auto"
alias ll="ls --color -l"
alias cplay="cplay -rR ~/sth.m3u"
alias zap="szap -rn"
alias dosbox="dosbox -c \"mount c /mnt/d/socke/alte_spiele\" -c \"c:\""

# Change the window title of X terminals 
case $TERM in
        xterm*|rxvt|Eterm|eterm|aterm)
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
                ;;
        screen)
                PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
                ;;
esac

Nichts besonderes..
 
Von allem etwas:

Code:
# This might be helpful for Linux newbies who previously used DOS...
test -f /etc/profile.dos && . /etc/profile.dos && ./profile.local

# Some applications read the EDITOR variable to determine your favourite text
# editor. So uncomment the line below and enter the editor of your choice :-)
#export EDITOR=/usr/bin/vim
export EDITOR=/usr/bin/mcedit

# For some news readers it makes sense to specify the NEWSSERVER variable here
#export NEWSSERVER=your.news.server

# If you want to use a Palm device with Linux, uncomment the two lines below.
# For some (older) Palm Pilots, you might need to set a lower baud rate
# e.g. 57600 or 38400; lowest is 9600 (very slow!)
#
export PILOTPORT=/dev/ttyS0
export PILOTRATE=115200

test -s ~/.alias && . ~/.alias

# colors for ls, etc.
eval `dircolors -b /etc/DIR_COLORS`
alias d="ls --color"
alias ls="ls --color=auto"
alias ll="ls --color -l"
alias lh="ls --color=auto -lh"

# You will thank me for this one day.
alias rm="rm -i"

# Biggest file in directory
alias ducks='du -chks * |sort -rn |head -11'

# Nano
alias nano='nano -w'

# Screen
alias screen='screen -R -D'

hs()
{
grep --color=auto -irn $* $HOME/.bash_history
}
# Search for string in files through dirs and subdirs (thanks to darkless)
alias finn='find . | xargs grep -HnI --color=auto'

# Change the window title of X terminals
case $TERM in
xterm*|rxvt|Eterm|eterm)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac

# Standard
source /etc/profile

# Extended bash-completion
[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion

# Set prompt
export PS1="\[\033[33m\]\t\[\033[01;00;0m\] [\[\033[34m\]\u@\h\[\033[01;00;0m\]][\[\033[32m\]\w\[\033[01;00;0m\]]\$ "

# PATH {{{
PATH=$PATH:"/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin"
 
btw. Warum nutzt ihr so ein umständliches Kommando, um die größte Datei in einem Verzeichnis zu ermitteln?
Einfacher gehts mit `ls -lahrS´...

3.
 
tux hat gesagt.:
Code:
#  Biggest file in directory
alias ducks='du -chks * |sort -rn |head -11'

dritter hat gesagt.:
btw. Warum nutzt ihr so ein umständliches Kommando, um die größte Datei in einem Verzeichnis zu ermitteln?
Einfacher gehts mit `ls -lahrS´...

Ja, also erstmal bietet das ls Kommando wirklich nur für Dateien eine nützliche Größenangabe. 'du' verarbeitet aber auch Verzeichnisse rekursiv und berichtet dessen Gesamtgröße (Option -s).

Außerdem berichtet ls nur die Größe der Dateien aber nicht wieviel Speicher diese auf der Platte belegen. Eine Datei kann sehr wohl mehrere 100 MiB gross sein, aber dennoch kaum ein paar KiB auf der Festplatte belegen wenn diese "Löcher" hat (ein "sparse file"). Deswegen verwendet man dann doch lieber 'du'.

Aber ein bißchen komisch ist das obige Alias für du schon, da die Optionen -k und -h sich gegenseitig ausschliessen :confused: und nur die letzte Option angwendet wird; sprich: man kann sich das -h in den Optionen auch sparen.

Nützlich ist in dem Zusammenhang mit ls z.B. auch 'ls -1sahrS' wenn einen hauptsächlich nur die Größe der Dateien interessiert.

Jetzt könnte man evtl. noch anführen, dass aber das 'ducks' Alias keine versteckten Dateien und Verzeichnisse berücksichtigt - es sei denn dotglob ist angeschaltet (shopt -s dotglob).

Dazu folgender Vorschlag:

alias duck='du -csk !(.) .!(.|) | sort -rn | head -n11'

Dazu sollte extended globbing eingeschaltet werden (shopt -s extglob), was aber sowieso meist der Fall ist, insbesondere wenn man die bash_completion verwendet.

Ansonsten kann man halt einfach immer dotglob an- und ausschalten.

Ach ja, dieser Alias befindet sich in meiner .bashrc:

alias l.='ls -d .!(.|)'

--
dt
 
Zurück