Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## .zshrc
- #
- ####################
- # GENERAL SETTINGS #
- ####################
- PATH=$HOME/.bin:$PATH
- umask 022
- ## display?
- if [ "$DISPLAY" ]; then
- export EDITOR=gvim \
- EXCEL=oocalc \
- OFFICE=oowriter \
- PDF="q epdfview" \
- PICSHOW="q mirage" \
- alias e="$EDITOR -p"
- alias eb="e $HOME/{.bashtweaks,.bashrc}" # open bash files
- alias en="e $HOME/.notes" # edit notes (also see function note() below)
- alias eo="e $HOME/.config/openbox/{rc.xml,menu.xml}" # edit openbox files
- alias ez="e $HOME/.zshrc" # edit zsh files
- alias m="q medit"
- alias mb="m $HOME/{.bashtweaks,.bashrc}" # open bash files
- alias mn="m $HOME/.notes" # medit notes (also see function note() below)
- alias mo="m $HOME/.config/openbox/{rc.xml,menu.xml}" # medit openbox files
- alias mz="m $HOME/.zshrc" # medit zsh files
- alias xp='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""' # get xprop CLASS and NAME
- ### set window title
- case $TERM in
- *xterm*|rxvt|rxvt-unicode|rxvt-256color|(dt|k|E)term)
- precmd() { print -Pn "\e]0;[%n@%M] [%~]\a" }
- preexec() { print -Pn "\e]0;[%n@%M] [%~] ($1)\a" }
- ;;
- screen)
- precmd() {
- print -Pn "\e]83;title \"$1\"\a"
- print -Pn "\e]0;[%n@%M] [%~]\a"
- }
- preexec() {
- print -Pn "\e]83;title \"$1\"\a"
- print -Pn "\e]0;[%n@%M]%# [%~] ($1)\a"
- }
- ;;
- esac
- es() { # use $EDITOR to edit a file but create a backup first
- cp -iv $1 ${1}.backup && gvim $1
- }
- t() {
- if ((LINES < 48));then
- printf %b "\033[8;48;80t"
- else
- printf %b "\033[8;24;80t"
- fi
- #sleep .1
- #echo "\$LINES = $LINES"
- }
- timer() { # remind me in n (s/m/h/d) about x
- (sleep "$1" && zenity --info --text "$2") &
- }
- fi
- ### environment
- ## exports
- LS_COLORS="no=00:fi=00:rs=0:di=04:ex=00:";
- export CC=/usr/bin/gcc \
- DIRSTACKSIZE=20 \
- GREP_OPTIONS=--color=auto \
- GREP_COLOR="1;36" \
- HISTFILE="$HOME/.zhistory" \
- HISTSIZE=5000 \
- LANG="en_US.utf8" \
- LC_ALL="en_US.utf8" \
- LC="en_US.utf8" \
- LESS="-MWi -x4 --shift 5" \
- LESSHISTFILE="-" \
- LS_COLORS \
- MPD_HOST=192.168.0.2 \
- MPD_PORT=6600 \
- SAVEHIST=$HISTSIZE \
- SHELL=/bin/zsh \
- VISUAL=vim
- ## setopt (see http://zsh.sourceforge.net/Doc/Release/zsh_15.html)
- setopt NO_ALL_EXPORT \
- ALWAYS_LAST_PROMPT \
- ALWAYS_TO_END \
- AUTO_CD \
- NO_AUTO_CONTINUE \
- AUTO_LIST \
- AUTO_PUSHD \
- NO_BEEP \
- NO_BG_NICE \
- BRACE_CCL \
- CASE_GLOB \
- CDABLE_VARS \
- CHASE_LINKS \
- NO_CHECK_JOBS \
- CLOBBER \
- COMPLETE_IN_WORD \
- CORRECT_ALL \
- DOT_GLOB \
- EXTENDED_GLOB \
- GLOB \
- GLOB_COMPLETE \
- HASH_LIST_ALL \
- HIST_APPEND \
- NO_HIST_BEEP \
- HIST_EXPIRE_DUPS_FIRST \
- HIST_FIND_NO_DUPS \
- HIST_IGNORE_ALL_DUPS \
- HIST_IGNORE_SPACE \
- HIST_NO_STORE \
- HIST_NO_FUNCTIONS \
- HIST_REDUCE_BLANKS \
- HIST_VERIFY \
- NO_HUP \
- IGNORE_EOF \
- INC_APPEND_HISTORY \
- NO_LIST_BEEP \
- LIST_PACKED \
- LIST_TYPES \
- NO_LONG_LIST_JOBS \
- MENU_COMPLETE \
- MULTIOS \
- NO_NOMATCH \
- NO_NOTIFY \
- NUMERIC_GLOB_SORT \
- NULL_GLOB \
- PROMPT_VARS \
- PUSHD_IGNORE_DUPS \
- PUSHD_SILENT \
- PUSHD_TO_HOME \
- NO_RM_STAR_WAIT \
- SHARE_HISTORY \
- NO_SH_WORD_SPLIT \
- NO_TRANSIENT_RPROMPT
- ### keybindings
- typeset -g -A key
- bindkey -e # use emacs keymap (cdp needs it too?)
- bindkey '^[OH' beginning-of-line # home
- bindkey '^[OF' end-of-line # end
- bindkey '^[[A' up-line-or-history # up
- bindkey '^[[D' backward-char # left
- bindkey '^[[B' down-line-or-history # down
- bindkey '^[[C' forward-char # right
- bindkey -M viins '^?' backward-delete-char # traditional backspace
- bindkey -M viins '^H' backward-delete-char
- bindkey '^[[1;3D' backward-word # alt + LEFT
- bindkey '^[[1;3C' forward-word # alt + RIGHT
- bindkey '^[[1;2D' beginning-of-line # shift + left
- bindkey '^[[1;2C' end-of-line # shift + right
- bindkey '^[[3~' delete-char # del
- bindkey '^[[3;3~' delete-word # alt + delete
- bindkey '^[[3;2~' delete-word # shift + delete
- bindkey '_^?' backward-delete-word # alt + backspace
- bindkey '^[' self-insert # alt + enter
- bindkey '^z' undo # ctrl + Z
- bindkey '^L' push-line # push current command into a buffer, allows you to do another command then returns to previous command
- ##bindkey '^t' 'if ((LINES < 48)); then printf %b "\033[8;48;80t"; else printf %b "\033[8;24;80t"; fi; sleep .1; echo "\$LINES = $LINES"'
- ### completion
- ## load
- autoload -Uz compinit
- compinit
- ## general completion settings
- zstyle ':completion:*:approximate:' max-errors 'reply=( $((($#PREFIX+$#SUFFIX)/3 )) numeric )' # allow one error for every three characters typed in approximate completer
- zstyle ':completion:*:*:cd:*:directory-stack' menu yes select # complete 'cd -<tab>' with menu
- zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~' # don't complete backup files as executables
- #zstyle ':completion:*' completer _complete _correct _approximate
- zstyle ':completion:*:correct:*' insert-unambiguous true # start menu completion only if it could find no unambiguous initial string
- zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}'
- zstyle ':completion:*:correct:*' original true #
- zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} # activate color-completion(!)
- zstyle ':completion:*:descriptions' format $'%{\e[0;33m%}%B%d%b%{\e[0m%}' # format on completion
- zstyle ':completion:*:expand:*' tag-order all-expansions # insert all expansions for expand completer
- #zstyle ':completion:*' expand prefix suffix
- zstyle ':completion:*:history-words' list false
- zstyle ':completion:*:history-words' menu yes # activate menu
- zstyle ':completion:*:history-words' remove-all-dups yes # ignore duplicate entries
- zstyle ':completion:*:history-words' stop yes
- zstyle ':completion:*' insert-tab pending # tab, don't annoy me
- #zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more or BACKSPACE to get out.%s'
- zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # match uppercase from lowercase
- zstyle ':completion:*:matches' group 'yes' # separate matches into groups
- zstyle ':completion:*' group-name ''
- zstyle ':completion:*' menu select=0 _complete _ignored _approximate
- zstyle ':completion:*:messages' format '%d'
- zstyle ':completion:*:options' auto-description '%d'
- zstyle ':completion:*:options' description 'yes' # describe options in full
- #zstyle ':completion:*:processes' command 'ps -au$USER' # on processes completion complete all user processes
- zstyle ':completion:*' select-prompt 'Scrolling active: current selection at %p. Hit BACKSPACE to get out.'
- zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters # offer indexes before parameters in subscripts
- zstyle ':completion:*' verbose true # provide verbose completion information
- zstyle ':completion:*:warnings' format $'%{\e[0;31m%}No matches for:%{\e[0m%} %d' # set format for warnings
- zstyle ':completion:*:*:zcompile:*' ignored-patterns '(*~|*.zwc)' # define files to ignore for zcompile
- zstyle ':completion:correct:' prompt 'correct to: %e' #
- zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*' # Ignore completion functions for commands you don't have:
- ## commands
- zstyle ':completion:*:manuals' separate-sections true
- zstyle ':completion:*:manuals.*' insert-sections true
- zstyle ':completion:*:man:*' menu yes select
- zstyle ':completion:*:rm:*' ignore-line yes
- zstyle ':completion:*:cp:*' ignore-line yes
- zstyle ':completion:*:mv:*' ignore-line yes
- zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
- zstyle ':completion:*:processes-names' command 'ps axho command'
- zstyle ':completion:*:*:killall:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
- zstyle ':completion:*:*:killall:*:processes' command 'ps --forest -A -o pid,user,cmd'
- zstyle ':completion:*:processes' command 'ps -au$USER -o pid,time,cmd|grep -v "ps -au$USER -o pid,time,cmd"'
- #zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)[ 0-9:]#([^ ]#)*=01;30=01;31=01;38'
- #zstyle ':completion:*:*:kill:*:processes' command 'ps --forest -A -o pid,user,cmd'
- _force_rehash() { # run rehash on completion
- (( CURRENT == 1 )) && rehash
- return 1 # Because we didn't really complete anything
- }
- # completion for "man" by Gossamer 980827
- compctl -f -x 'S[1][2][3][4][5][6][7][8][9]' -k '(1 2 3 4 5 6 7 8 9)' \
- - 'R[[1-9nlo]|[1-9](|[a-z]),^*]' -K 'match-man' \
- - 's[-M],c[-1,-M]' -g '*(-/)' \
- - 's[-P],c[-1,-P]' -c \
- - 's[-S],s[-1,-S]' -k '( )' \
- - 's[-]' -k '(a d f h k t M P)' \
- - 'p[1,-1]' -c + -K 'match-man' \
- -- man
- ### system wide functions
- ## backup
- bu() { # create backup in working directory
- cp "$1" ${1}-`date +%Y%m%d%H%M`.backup
- }
- buh() { # create backup in $HOME/.backup
- bakdir="$HOME/.backup"
- [ ! -d "$bakdir" ] && mkdir -p -m 700 "$bakdir"
- for f in "$@"; do
- f="`echo "$f" | sed 's!/\+$!!'`" # strip trailing slashes
- command cp -ai "$f" "$HOME/.backup/$f-`date +'%Y%m%d%H%M'`"
- done
- }
- bur() { # create recursive backup in $HOME/.backup maintaining file system structure
- if [ "`dirname $1`" == "." ]; then
- mkdir -p $HOME/.backup/`pwd`;
- cp -r "$1" $HOME/.backup/`pwd`/$1-`date +%Y%m%d%H%M`.backup;
- else
- mkdir -p $HOME/.backup/`dirname $*`;
- cp -r "$1" $HOME/.backup/$1-`date +%Y%m%d%H%M`.backup;
- fi
- }
- ## pushd and cdp
- cd() { # always ls when cd'ing, also use pushd so i can retrace my steps via popd
- if [ "$1" ]
- then builtin pushd "$@" && ls
- else builtin pushd && ls
- fi
- }
- cdp() { # change directory (Author W.Friebel friebel@ifh.de 13/04/95)
- TRAPINT() {
- bindkey "^M" accept-line
- setopt +B
- trap - INT
- builtin let "$1 > 0" && return $[128+$1]
- }
- setopt -B
- bindkey -s "^M" "^X^W"
- bindkey "^[k" kill-region
- # Select_Key definition:
- # to column 2; to begin of line; insert cd ;
- # to begin of line; mark position; to begin of buffer; delete up to mark
- # to end of line; mark position; to end of buffer; to end of line
- # delete up to mark; put cd command into input buffer and execute
- bindkey -s "^X^W" "^[2^[|^A cd ^A^@^[<^[k^E^@^[>^E^[k^[a^X^K"
- cdp_var=`builtin print "### Select (and Edit) directory, Enter to accept it, ^C to quit ###"
- builtin print -l \`dirs \``
- vared cdp_var
- bindkey "^M" accept-line
- setopt +B
- eval $cdp_var
- }
- ## system wide functions
- # daemon control
- dreload() { # reload a daemon
- if [ "$UID" = 0 ];then
- for arg in $*; do
- /etc/rc.d/$arg reload
- done
- else
- for arg in $*; do
- sudo /etc/rc.d/$arg reload
- done
- fi
- }
- drestart() { # reload a daemon
- if [ "$UID" = 0 ];then
- for arg in $*; do
- /etc/rc.d/$arg restart
- done
- else
- for arg in $*; do
- sudo /etc/rc.d/$arg restart
- done
- fi
- }
- dstart() { # reload a daemon
- if [ "$UID" = 0 ];then
- for arg in $*; do
- /etc/rc.d/$arg start
- done
- else
- for arg in $*; do
- sudo /etc/rc.d/$arg start
- done
- fi
- }
- dstat() { # reload a daemon
- if [ "$UID" = 0 ];then
- for arg in $*; do
- /etc/rc.d/$arg status
- done
- else
- for arg in $*; do
- sudo /etc/rc.d/$arg status
- done
- fi
- }
- dstop() { # reload a daemon
- if [ "$UID" = 0 ];then
- for arg in $*; do
- /etc/rc.d/$arg stop
- done
- else
- for arg in $*; do
- sudo /etc/rc.d/$arg stop
- done
- fi
- }
- # file operations
- dirsize() { # show size of all directories in current working directory
- du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
- egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
- egrep '^ *[0-9.]*M' /tmp/list
- egrep '^ *[0-9.]*G' /tmp/list
- rm /tmp/list
- }
- f() { # find a file
- find 2>/dev/null | grep -is "$1"
- }
- fc() { # search content
- if [ $# -eq 0 ]; then
- echo "findcontent: No arguments entered."; return 1
- else
- # "{.[a-zA-Z],}*" instead of "." makes the output cleaner
- find {.[a-zA-Z],}* -type f 2>/dev/null | xargs grep -is --color=always -n "$@"
- fi
- }
- fcd() { # search content and specify the path to look
- if [ $# -eq 0 ]; then
- echo "findcontent: No arguments entered."; return 1
- else
- # "{.[a-zA-Z],}*" instead of "." makes the output cleaner
- find "$1" -type f 2>/dev/null | xargs grep -is --color=always -n "$2"
- fi
- }
- fd() { # specify where find should look
- find "$1" 2>/dev/null | grep -is "$2"
- }
- ff() { # find a file in my filesystem
- find / 2>/dev/null | grep -is "$1"
- }
- cdiff() { # create a diff
- diff -udrP "$1" "$2" > diff.$(date "+%Y-%m-%d")."$1"
- }
- lf() { # list files only
- ls -a1p $@ | grep -v '\/$'
- }
- sanitize() { # change mode and users of files to safe default
- chmod -R u=rwX,go=rX "$@"
- chown -R ${USER}:users "$@"
- }
- vs() { # use vim to edit a file but create a backup first
- cp -iv $1 ${1}.backup && $VISUAL $1
- }
- wgp() { # paste file at paste.pocoo.org
- wgetpaste "$@"
- }
- ### system wide aliases
- ## globals and suffixes
- alias -s {conf,java,txt,TXT,README,PKGBUILD}=$VISUAL
- alias -g G="| grep"
- alias -g M="| most"
- alias -g X="| xargs"
- alias -g H="| head"
- alias -g T="| tail"
- alias -g S="| sort"
- alias -g SU='|sort -u'
- alias -g SN='|sort -n'
- alias -g SNR='|sort -nr'
- alias -g W="| wc -l"
- alias -g N="&>/dev/null"
- alias -g 1N="1>/dev/null"
- alias -g 2N="2>/dev/null"
- ## mpd
- alias cmpd="ncmpc --host=192.168.0.2"
- alias lock="pause && slock && play"
- alias mt="amixer -q set Master toggle"
- alias mvol="mpc --no-status volume $1"
- alias nxt="mpc --no-status next"
- alias pause="mpc --no-status pause"
- alias pl="mpc --no-status playlist"
- alias play="mpc --no-status play"
- alias rnd="mpc random G random"
- alias rpt="mpc repeat G repeat"
- alias shfl="mpc --no-status shuffle"
- alias sta="mpc status"
- alias svol="amixer set Master $1"
- alias tog="mpc --no-status toggle"
- alias la="ll -A" # list all but not . and ..
- alias lh="ls -ld .*" # list only hidden files and folders
- alias ld="ls -ld *(-/DN)" # list only directories and link to them (see also lf())
- alias ll="ls -l" # list detailed with human-readable sizes
- alias lsd="ll /var/run/daemons" # list running daemons
- alias lsdev="ls /dev | grep sd" # list sata devices
- alias rm="rm -Iv" # secure remove but less annoying than -i
- alias rmr="rm -r" # including folders
- #################
- # ROOT SETTINGS #
- #################
- if [[ $UID == 0 ]]; then
- # close root shell after n seconds for security reasons
- export TMOUT=180
- # root prompt
- PROMPT=$'%{\e[0;31m%} #%{\e[0m%} '
- RPROMPT='[%~] %*'
- # root aliases
- alias hlt="shutdown -h now" # halt now
- alias hltin="shutdown -h" # halt in n minutes
- alias mnt="mount" # mount
- alias rbt="shutdown -r now" # reboot now
- alias rbtin="shutdown -r" # reboot in n minutes
- alias showlog="tail -f /var/log/everything.log"
- #alias sublimation="pacman -R $(pacman -Qq | grep -v "$(pacman -Qqg base)")" # careful! deletes every package except for those in the base group
- alias suspend="pm-suspend" # suspend
- alias umnt="umount" # umount
- if [ $HOST = 13 ]; then
- fan() { # control fan
- if [ $# = 0 ];then
- cat /proc/acpi/ibm/fan
- elif [ $1 = off ];then
- echo disable > /proc/acpi/ibm/fan
- elif [ $1 = on ];then
- echo level auto > /proc/acpi/ibm/fan
- elif [ $1 = 1 ];then
- echo level 1 > /proc/acpi/ibm/fan
- else
- echo "$@" > /proc/acpi/ibm/fan
- fi
- }
- fi
- lamb() { # beep the children's song
- beep -f 10
- echo "Marry Had A Little Lamb"
- beep -f 466.2 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 370.0 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 466.2 -l 250 -r 2 -d 0 -D 20 -n -f 466.2 -l 500 -n -f 10 -l 20
- echo "Little Lamb, Little Lamb"
- beep -f 415.3 -l 250 -r 2 -d 0 -D 20 -n -f 415.3 -l 500 -D 20 -n -f 466.2 -l 250 -D 20 -n -f 568.8 -l 250 -D 20 -n -f 568.8 -l 500 -n -f 10 -l 20
- echo "Marry Had A Little Lamb"
- beep -f 466.2 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 370.0 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 466.2 -l 250 -r 2 -d 0 -D 20 -n -f 466.2 -l 250 -n -f 10 -l 20
- echo "Whose Fleece Was White As Snow"
- beep -f 415.3 -l 250 -r 3 -D 20 -n -f 466.2 -l 250 -D 20 -n -f 415.3 -l 250 -D 20 -n -f 370.0 -l 500
- }
- setup() { # setup choosing between demian and slave
- echo -n "intial-setup: demian or slave? "
- read answer
- case "$answer" in
- demian|d|1|"") echo "Proceeding with setup for demian"
- echo "Creating user demian, directories and password"
- useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/zsh demian ; passwd demian ; mkdir /media/share /media/daten
- echo "Downloading and installing packages"
- ## Base System
- pacman -Syy irssi grc unace zenity zsh cpufrequtils nfs-utils rpcbind rsync wgetpaste tree calc vim bc htop scrot curl unzip rar p7zip unrar screen clamav dosfstools ntfsprogs alsa-utils powertop laptop-mode-tools acpid pm-utils abs cups pmount samba openssh ntfs-3g slock mpc moc ethtool imagemagick yaourt lm_sensors stress reflector lzop cowsay fortune-mod ; yaourt -Sy --aur fortune-mod-tbbt fortune-mod-montypython fortune-mod-himym fortune-mod-buffy fortune-mod-chucknorris tupac zsh-tupac zsh-yaourt zsh-lovers
- ## GUI
- pacman -S ttf-dejavu ttf-ms-fonts ttf-bitstream-vera xorg xf86-input-evdev xf86-video-intel gamin openbox openbox-themes obconf obmenu xcompmgr terminal feh pcmanfm gmrun medit xarchiver epdfview mirage conky sonata gmpc firefox thunderbird flashplugin galculator vlc transset-df gxmessage xdg-user-dirs gvim ; yaourt -S aurvote firebrand thunderbrand sir
- ## LCD-Fonts
- pacman -Rd libxft cairo ; yaourt -S fontconfig-lcd cairo-lcd ; pacman -S libxft-lcd
- ;;
- slave|s|2|"") echo "Proceeding with install for slave"
- echo "Creating user slave, directories and password"
- useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/zsh slave ; passwd slave ; mkdir /media/movies /media/music /media/series /media/share /media/usbhdd
- echo "Downloading and installing packages"
- ## Base System
- pacman -Syy lighttpd fcgi php php-cgi mpd rtorrent irssi grc unace zenity zsh cpufrequtils nfs-utils rpcbind rsync wgetpaste tree calc vim bc htop scrot curl unzip rar p7zip unrar screen clamav dosfstools ntfsprogs alsa-utils powertop laptop-mode-tools acpid pm-utils abs cups pmount samba openssh ntfs-3g slock mpc moc gmpc ethtool imagemagick yaourt lm_sensors stress reflector lzop cowsay fortune-mod ; yaourt -Sy --aur fortune-mod-tbbt fortune-mod-montypython fortune-mod-himym fortune-mod-buffy fortune-mod-chucknorris tupac eaccelerator zsh-tupac zsh-yaourt zsh-lovers
- ## GUI
- pacman -S ttf-dejavu ttf-ms-fonts ttf-bitstream-vera xorg xf86-input-evdev xf86-video-intel gamin openbox openbox-themes obconf obmenu xcompmgr terminal feh pcmanfm gmrun medit xarchiver epdfview mirage conky sonata gmpc firefox thunderbird flashplugin galculator vlc transset-df gxmessage xbmc xdg-user-dirs gvim ; yaourt -S aurvote firebrand thunderbrand sir
- ## LCD-Fonts
- pacman -Rd libxft cairo ; yaourt -S fontconfig-lcd cairo-lcd ; pacman -S libxft-lcd
- ;;
- *) echo "Error. Please go away."
- ;;
- esac
- }
- # root stops parsing this file here
- return 0
- fi
- #################
- # USER SETTINGS #
- #################
- ### general settings
- ## user prompt
- PROMPT=" > "
- RPROMPT="[%~] %*"
- ## greeting
- dir="/usr/share/cows"
- file=`/bin/ls -1 "$dir" | sort --random-sort | head -1`
- cow="$(echo "$file" | sed -e "s/\.cow//")"
- fortune | cowsay -W 75 -f $cow
- ## exports
- export XAUTHORITY="$HOME/.Xauthority" \
- XDG_CACHE_HOME="$HOME/.cache" \
- XDG_CONFIG_DIR="$HOME/.config" \
- XDG_CONFIG_DIRS="$HOME/.config:/etc" \
- XDG_DATA_HOME="$HOME/.config/share" \
- XDG_DESKTOP_DIR="$HOME" \
- XDG_DOCUMENTS_DIR="$HOME/doc" \
- XDG_DOWNLOAD_DIR="$HOME/down" \
- XDG_MUSIC_DIR="$HOME" \
- XDG_PICTURES_DIR="$HOME/pics" \
- XDG_PUBLICSHARE_DIR="$HOME" \
- XDG_TEMPLATES_DIR="$HOME" \
- XDG_VIDEOS_DIR="$HOME"
- if [ "$DISPLAY" ]; then
- export BROWSER=.bin/firefox \
- VIDEO=vlc
- alias -s {PDF,pdf}=$PDF
- alias -s {docx,DOCX,doc,DOC,odt,ODT,sxw}=$OFFICE
- alias -s {ods,xls}=$EXCEL
- alias -s {jpg,JPG,jpeg,JPEG,png,PNG,gif,GIF}=$PICSHOW
- alias -s xcf="q gimp"
- alias -s svg="q inkscape"
- alias -s {MP3,mp3,ogg,wav,WAV,flac,FLAC,mpg,mpeg,avi,AVI,ogm,wmv,m4v,mp4,mov,mkv,MKV}=$VIDEO
- alias -s {com,net,org,uk,html,php,url}=$BROWSER
- alias firefox="q .bin/firefox" # firefox
- alias pc="q mirage" # start mirage disowned with no stdout
- alias pf="q epdfview" # start epdfview disowned with no stdout
- alias regex="pc $HOME/.local/regex.png" # show regex cheatsheet
- alias se="sudo e" # $EDITOR
- alias session="q session" # .bin/session
- alias sm="sudo m" # medit
- alias vlc="q vlc" # run vlc quietly
- ses() { # es but with sudo privileges
- sudo cp -iv "$1" ${1}.backup && sudo $EDITOR "$1"
- }
- fi
- ## which host?
- if [ $HOST = 2 ]; then
- alias cdi="cd /media/music/incoming" # change directory to incoming
- alias cdmo="cd /media/movies" # change directory to movies
- alias cdmu="cd /media/music" # change directory to music
- alias cds="cd /media/series" # change directory to series
- alias cdu="cd /media/usbhdd" # change directory to usbhdd
- alias lsi="lx /media/music/incoming" # list incoming
- alias mntu="mount /media/usbhdd" # mount usbhdd
- elif [ $HOST = 13 ]; then
- alias bats="c /proc/acpi/battery/BAT0/state" # show battery state
- alias cdd="cd /media/daten/down" # change directory to incoming
- alias mnth="mount 192.168.0.2:/home/slave $HOME/.shares/home ; cd $HOME/.shares/home" # mount NFS home
- alias mntm="mount 192.168.0.2:/media $HOME/.shares/media ; cd $HOME/.shares/media" # mount NFS media
- alias ssh2="ssh slave@192.168.0.2" # ssh into 2
- alias umnth="sudo umount.nfs 192.168.0.2:/home/slave" # umount nfs home
- alias umntm="sudo umount.nfs 192.168.0.2:/media" # umount nfs media
- alias wc="wicd-curses" # wicd
- alias wup="ifconfig wlan0 up" # ifconfig
- fi
- ### aliases
- ## short ones
- alias a=cat
- alias b=popd
- alias c=cd
- alias d=pwd
- #f: find in wd
- alias g=grep
- alias h=history
- alias k="kill"
- alias l=ls
- alias n=note
- #t: toggle terminal size
- #q: run quietly and disowned
- alias v="$VISUAL -p"
- alias x=exit
- #y: yaourt
- ## system
- alias ..="cd ../" # move up one directory
- alias ...="cd ../../" # move up two directories
- alias ....="cd ../../../" # move up three directories
- alias 000="chmod 000"
- alias 644="chmod 644"
- alias 755="chmod 755"
- alias cdb="cd $HOME/.backup" # change directory to $HOME/.backup
- alias cdbin="cd $HOME/.bin" # change directory to .bin
- alias cdt="cd /tmp" # change directory to /tmp
- alias chr="chmod a+r" # add read permissions for all users
- alias chw="chmod a+w" # add write permissions for all users
- alias cd.s="cd $HOME/.shares" # change directory to .shares
- alias cdm="cd /media" # change directory to media
- alias cdscr="cd $HOME/.local/screenshots" # change directory to screenshots
- alias cdsh="cd /media/share" # change directory to share
- alias cdwp="cd $HOME/.local/wallpapers" # change directory to wallpapers
- alias cl="clear" # clear screen
- alias clam="clamscan --bell -i" # scan a file
- alias clami="clam -r /media/music/incoming" # scan incoming files
- alias clamt="clam -r /tmp" # scan /tmp
- alias cm="chmod" # chmod
- alias cpr="cp -r" # copy recursively
- alias cpv="rsync -P" # use rsync as cp alternative due to more information
- alias co="chown" # chown
- alias cx="chmod a+x" # make file executable for everyone
- alias da="date '+%A, %d.%m.%Y, %T'" # Wednesday, 21.04.2010, 14:22:25
- alias dat="date '+%A, %B %d, %Y [%T]'" # Thursday, April 15, 2010 [16:27:42]
- alias df="df -h" # file system disk space usage in human-readable sizes
- alias du="du -hc" # disk space usage in human-readable sizes
- alias du1="du --max-depth=1" # look no deeper than one directory level
- alias dus="du -s" # disk space usage in human-readable sizes
- alias duchs="du -chs * 2>/dev/null |sort -rn |head -11" # disk hog
- alias eg="egrep --color=auto" # colourized egrep
- alias egrep="egrep --color=auto" # colourized egrep
- alias free="free -m" # show sizes in MB
- alias hist="history | grep" # search cmd history
- alias ka="killall" # killall
- alias lam="la | less" # long list?
- alias lat="lt -A" # lt with -A
- alias lax="lx -A" # lx with -A
- alias lay="ly -A" # ly with -A
- alias less="less -iF" # less with ignore-case and quit-if-one-screen enabled
- alias llm="ll | less" # long list?
- alias lnew="ll -rt *(.) | tail" # list newest
- alias lold="ll -rt *(.) | head" # list oldest
- alias ls="ls --color=always -hF" # classify and human-readable
- alias lsb="la $HOME/.backup" # list content of .backup
- alias lscr="ll $HOME/.local/screenshots" # list screenshots
- alias lsmall='ls -lSh *(.) | head' # list smallest
- alias lst="ll /tmp" # list temporary directory
- alias lsuuid="ls -l /dev/disk/by-uuid/" # list disks by uuid
- alias lt="la -rt" # sort by modification time
- alias lw="ls -1" # windows-style list
- alias lx="ll -BX" # sort by extension
- alias ly="ll -rS" # sort by size
- alias make="time make" # time make
- alias makepkg="time makepkg" # time makepkg
- alias md="mkdir -pv" # create parents and verbose output
- alias mtd='tdir=`mktemp -d` && cd $tdir' # make temp dir and cd into it
- alias more="less" # less is more
- alias nano="vim" # .
- alias ns="netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail"
- alias nsw="sudo watch -n 3 -d -t netstat -vantp" # watch incoming connections
- alias openports="netstat --all --numeric --programs --inet"
- alias parts="cat /proc/partitions" # show partitions
- alias pas="ps -efH" # all processes, in hierarchy and full-format listing
- alias pac0="ps aux | sort -k 3,3 | tail " # list processes by cpu usage
- alias pac1='ps -eo pcpu,nice,stat,time,pid,cmd --sort=-pcpu,-time | sed "/^ 0.0 /d"'
- alias pag="ps aux | grep -v grep | grep" # search process
- alias pam="echo '%CPU %MEM PID COMMAND' && /bin/ps hgaxo %cpu,%mem,pid,comm | sort -nrk1 | head -n 10 | sed -e 's/-bin//' | sed -e 's/-media-play//'"
- alias par0="ps aux | sort -k 4,4 | tail " # list processes by memory usage
- alias par1='ps -eo rss,vsz,pid,cmd --sort=-rss,-vsz | awk "{ if (\$1 > 10000) print }"'
- alias pau="ps uxU $1" # list processes by user
- alias pk="pkill" # pkill
- alias pm="pmount" # pmount
- alias pum="pumount" # pumount
- alias pw='echo `< /dev/urandom tr -cd "[:graph:]" | head -c8`' # create secure password
- alias rd="rmdir" # remove directory
- alias rsynn="rsync -r -n -t -p -o -g -v --progress --delete -l"
- alias trace="traceroute -I" # tracerout using icmp echo instead of udp datagrams
- alias tree="tree -C" # colorize tree output
- alias vb="v $HOME/{.bashtweaks,.bashrc}" # visual edit bash files
- alias vn="v $HOME/.notes" # visual edit notes (also see function note() below)
- alias vz="v $HOME/.zshrc" # visual edit zsh files
- ## .bin
- #alias archinfo="archinfo" # shows DE/WM information
- alias bat="bat -b0" # battery information
- #alias firefox="firefox" # wrapper for firefox
- #alias mod="mod" # shows required kernel modules
- #alias pclean="pclean" # clean pacman database
- #alias pfree="pfree" # shows files that are not owned by any package
- #alias psizee="psizee" # sorts all installed packages by size
- #alias pwcat="pwcat" # show power setting information (needs redo)
- #alias pwdo="pwdo" # execute power settings (needs redo)
- #alias q="q" # run program quietly and detached from terminal
- #alias read_msr="read_msr" # used to verify undervolting controls
- #alias rndwp="rndwp" # random wallpaper!
- #alias session="session" # used with gxmessage to create popup for session control
- #alias temp="temp" # show temperatures (needs redo)
- ## colorize
- if which grc &>/dev/null; then
- alias .cl='grc -es --colour=auto'
- alias configure='.cl ./configure'
- alias diff='.cl diff'
- alias make='.cl make'
- alias gcc='.cl gcc'
- alias g++='.cl g++'
- #alias as='.cl as'
- #alias gas='.cl gas'
- #alias ld='.cl ld'
- alias netstat='.cl netstat'
- alias ping='.cl ping -c 5'
- alias traceroute='.cl traceroute'
- fi
- ## user
- alias irc="irssi -n mikar" # irc
- alias or="openbox --reconfigure" # reconfigure openbox
- alias sdr="screen -D -R $1" # if session is running, reattach. if necessary detach and logout remotely first. if it was not running create it and notify the user.
- alias sls="screen -ls" # lists pid.tty.host strings
- alias ss="screen -S $1" # start session specifying a name
- alias vo="v $HOME/.config/openbox/{rc.xml,menu.xml}" # visual edit openbox files
- ## pacman
- alias pqg="pacman-color -Qg | sed 's/ .*//' | sort | uniq" # list groups of installed packages
- alias psl="pacman-color -Sl | grep -i " # search pacman-color database for string
- #alias pfree="pfree" # create list of all files not owned by any package
- #alias psizea="psizea" # list all installed packages and sort by size
- #alias psizee="psizee" # list explicitly installed packages and sort by si
- ## tupac (wrapper for yaourt and pacman with local caching)
- alias y="tupac" # tupac
- alias yq="tupac -Q | grep -i" # query
- alias yqe="tupac -Qe" # show explicitly installed packages
- alias yqi="tupac -Qi" # show information about an installed package
- alias yql="tupac -Ql" # show files installed by a package
- alias yqo="tupac -Qo" # search for package that owns the file
- alias yqs="tupac -Qs" # search installed packages
- alias yr="tupac -R" # remove
- alias yrd="tupac -Rd" # remove omitting dependencies
- alias yrs="tupac -Rs" # remove including unused dependencies
- alias ys="tupac -S" # download and install
- alias ysb="tupac -Sb" # builds the targets from source
- alias ysc="tupac -Sc" # clean those packages from cage that are no longer installed
- alias yscc="tupac -Scc" # clean the whole cache directory
- alias ysf="tupac -Sf" # force (re-)installation
- alias ysi="tupac -Si" # show information about a non-local package
- alias ysl="tupac -Sl | grep -i " # list all packages in specified repository
- alias yss="tupac -Ss" # query database
- alias ysw="tupac -Sw" # download but don't install
- alias ysu="tupac -Su --aur" # upgrade all aur packages
- alias ysy="tupac -Sy --aur" # sync refresh
- alias ysyu="tupac -Syu --aur" # sync refresh sys update + aur
- alias ysyy="tupac -Syy --aur" # force sync refresh + aur
- alias ysyyu="tupac -Syyu --aur" # force sync refresh and update + aur
- alias yu="tupac -U" # install local package
- # sudo user aliases
- alias abs="sudo abs" # update abs database
- alias chi="sudo chattr +i" # immunize file
- alias chu="sudo chattr -i" # unimmunize file
- alias clams="sudo clam -r -l $HOME/.clamlog /" # scan whole system
- alias freshc="dstart clamav ; freshclam ; dstop clamav" # update clamav database
- alias freshclam="sudo freshclam" # freshclam
- alias hdparm="sudo hdparm" # hdparm
- alias hlt="sudo shutdown -h now" # halt now
- alias hltin="sudo shutdown -h" # halt in n minutes
- alias mkinitcpio="sudo mkinitcpio" # mkinitcpio
- alias ifconfig="sudo ifconfig" # ifconfig
- alias mnt="mount" # mount
- alias modprobe="sudo modprobe" # modprobe
- alias mount="sudo mount" # mount
- alias p="sudo pacman" # sudo pacman-color
- alias pin="sudo pacman-color -S" # install
- alias pout="sudo pacman-color -R" # remove
- alias pq="sudo pacman-color -Q | grep -i" # query
- alias pqe="sudo pacman-color -Qe" # show explicitly installed packages
- alias pqi="sudo pacman-color -Qi" # show information about an installed package
- alias pql="sudo pacman-color -Ql" # show files installed by a package
- alias pqo="sudo pacman-color -Qo" # search for package that owns the file
- alias pqs="sudo pacman-color -Qs" # search installed packages
- alias prd="sudo pacman-color -Rd" # remove omit dependencies
- alias prs="sudo pacman-color -Rs" # remove plus unused dependencies
- alias psc="sudo pacman-color -Sc" # clean those packages from cage that are no longer installed
- alias pscc="sudo pacman-color -Scc" # clean the whole cache directory
- alias psf="sudo pacman-color -Sf" # force (re-)installation
- alias psi="sudo pacman-color -Si" # show information about a non-local package
- alias pss="sudo pacman-color -Ss" # query database
- alias psw="sudo pacman-color -Sw" # download but don't install
- alias psu="sudo pacman-color -Su" # sys update without refresh
- alias psy="sudo pacman-color -Sy" # sync refresh
- alias psyu="sudo pacman-color -Syu" # sync refresh and update
- alias psyy="sudo pacman-color -Syy" # force all db to be refreshed
- alias psyyu="sudo pacman-color -Syyu" # force refresh and update
- alias pu="sudo pacman-color -U" # install local pkg
- alias pclean="sudo pclean" # .bin/pclean with sudo privileges
- alias pmirror="sudo reflector -l 8 -r -o /etc/pacman.d/mirrorlist ; c /etc/pacman.d/mirrorlist" update mirrorlist
- alias popt="sudo pacman-optimize" # defrag pacman database
- alias porph="sudo pacman -Rsc $(pacman -Qtdq)" # remove orphans
- alias powertop="sudo powertop" # powertop
- alias rbt="sudo shutdown -r now" # reboot now
- alias rbtin="sudo shutdown -r" # reboot in n minutes
- alias rmmod="sudo rmmod" # rmmod
- alias s="sudo" # lazy much
- alias sa="sudo a" # cat
- alias s-cp="sudo cp" # cp -i
- alias scpr="sudo cpr" # cp -r
- alias showlog="sudo tail -f /var/log/everything.log"
- alias sk="sudo k" # kill -9
- alias smv="sudo mv" # mv -i
- alias spk="sudo pk" # pkill
- alias srm="sudo rm" # rm -I
- alias srmr="sudo rmr" # rm -Ir
- alias su="su -" # change to root directory
- alias sudo="sudo " # avoid some problems with sudo
- alias suspend="sudo pm-suspend" # suspend
- alias sv="sudo v" # $VISUAL
- alias umnt="sudo umount" # umount
- alias updfonts="sudo fc-cache -vf" # update font cache
- ## unalias everything
- #unalias -a # uncomment to unalias everything
- ### user functions
- ## various
- del() { # manage trash can
- if [ -z $1 ]; then
- la $HOME/.local/trash
- echo "Empty Trash? (y/n)"
- read var
- if [ $var = y ]; then
- sudo rm -rf $HOME/.local/trash/*
- echo "Emptied trash."
- else
- echo "Doing nothing."
- fi
- elif [ -f $1 ]; then
- echo "Delete or just move to trash? (d/t)?"
- read var
- if [ $var = t ]; then
- mv -v $1 $HOME/.local/trash/
- elif [ $var = d ]; then
- rm -rI $1
- else
- echo 'The requested file/folder, $1, does not exist'
- fi
- fi
- }
- note() { # create or show notes
- #if file doesn't exist, create it
- [ -f $HOME/.notes ] || touch $HOME/.notes
- #no arguments, print file
- if [ $# = 0 ]
- then
- cat $HOME/.notes
- #clear file
- elif [ $1 = -c ]
- then
- > $HOME/.notes
- #add all arguments to file
- else
- echo "$@" >> $HOME/.notes
- fi
- }
- reprobe() { # remove and reinsert module
- sudo modprobe -r $1
- sudo modprobe $1
- }
- ## file operations
- cpd() {
- [ ! -d "$2" ] && mkdir -p "$2"
- cp "$1" "$2"
- }
- cpg() { # copy file and go to dir
- if [ -d "$2" ];then
- cp -irv $1 $2 && cd $2
- else
- cp -irv $1 $2
- fi
- }
- files() { # show amount of files in a directory
- ls -Al $1 | wc -l
- }
- findopen() { # find and open a file
- local PS3="select file: "
- files=( $(find "$1" -iname "$2" | sort | tr ' ' '@') )
- select file in "${files[@]//@/ }"; do
- ${3:-exo-open} "$file"
- break
- done
- }
- grab() { # change ownership to me
- sudo chown -R ${USER}:${USER} ${1:-.}
- }
- lcfiles() { # lowercase all files in a directory
- print -n 'Really lowercase all files? (yn) '
- if read -q ; then
- for i in * ; do
- mv $i $i:l
- done
- fi
- }
- mdc() { # make directory and cd into it
- mkdir -p "$1" && cd "$1"
- }
- mvd() {
- [ ! -d "$2" ] && mkdir -p "$2"
- mv "$1" "$2"
- }
- mvg() { # move file and go to dir
- if [ -d "$2" ];then
- mv -iv $1 $2 && cd $2
- else
- mv -iv $1 $2
- fi
- }
- rmspaces() {
- ls | while read -r FILE
- do
- mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'`
- done
- }
- rme() { # remove everything except $1
- rm -r ^("$1"|"$2")
- }
- space() { # create report of biggest files in folder $@
- du -h "$@" | sort -nr > $HOME/.space.txt && vim $HOME/.space.txt
- }
- ssanitize() { # sanitize but with sudo privileges
- sudo chmod -R u=rwX,go=rX "$@"
- sudo chown -R ${USER}:users "$@"
- }
- svs() { # vs but with sudo privileges
- sudo cp -iv "$1" ${1}.backup && sudo $VISUAL "$1"
- }
- swap() { # swap two filenames
- if [ $# -ne 2 ]; then
- echo "swap: 2 arguments needed"; return 1
- fi
- if [ ! -e $1 ]; then
- echo "swap: $1 does not exist"; return 1
- fi
- if [ ! -e $2 ]; then
- echo "swap: $2 does not exist"; return 1
- fi
- local TMPFILE=tmp.$$ ; mv $1 $TMPFILE ; mv $2 $1 ; mv $TMPFILE $2
- }
- up() { # go up n directories
- [ "${1/[^0-9]/}" == "$1" ] && {
- local ups=""
- for i in $(seq 1 $1)
- do
- ups=$ups"../"
- done
- cd $ups
- } || echo "usage: up INTEGER"
- }
- ## pacman
- psizea() { # list all packages and sort them by their (installed) size
- LANG=C pacman -Qi | sed -n '/^Name[^:]*: \(.*\)/{s//\1 /;x};/^Installed[^:]*: \(.*\)/{s//\1/;H;x;s/\n//;p}' | sort -nk2
- }
- roulette() { # pacman roulette
- sudo pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
- }
- ## pictures
- res() { # resize a picture to 1920 x 1200 at 90% quality
- #no arguments, print usage
- if [ $# = 0 ]
- then
- echo "Usage: res filename"
- echo "Example: res P103845.JPG"
- else
- echo "Resizing ${i:2} to 1920 x 1200 at 90% quality with filename res-$1";convert -resize 1920x1200 -quality 90 $1 res-$1
- fi
- }
- resa() { # resize and replace all pictures in a directory
- #no arguments, print usage
- if [ $# = 0 ]
- then
- echo "Usage: resa width height quality"
- echo "Example: resa 1920 1200 90"
- else
- for i in $(find . -maxdepth 1 -type f \-iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.bmp");
- do
- echo "Resizing ${i:2} to $1 x $2 at $3% quality";convert ${i:2} -quality $3 -resize $1\x$2 new_${i:2}; /bin/mv new_${i:2} ${i:2}
- done
- fi
- }
- ress() { # resize a single picture specifying width, height, quality and filename
- #no arguments, print usage
- if [ $# = 0 ]
- then
- echo "Usage: ress width height quality filename"
- echo "Example: ress 1920 1200 90 P103845.JPG"
- else
- echo "Resizing ${i:2} to $1 x $2 at $3% quality with filename ress-$4";convert -resize $1\x$2 -quality $3 $4 ress-$4
- fi
- }
- rest() { # create thumbnail of pictures and move them to the directory final
- fmt="jpg"
- imgsz="100%"
- tmbsz="15%"
- id=1
- while [ $# -gt 0 ] ; do
- case "$1" in
- -f)
- fmt=$2 ; shift 2 ;;
- -i)
- imgsz=$2 ; shift 2 ;;
- -t)
- tmbsz=$2 ; shift 2 ;;
- -n)
- id=$2 ; shift 2 ;;
- -s)
- sfx=$2 ; shift 2 ;;
- -p)
- pfx=$2 ; shift 2 ;;
- *)
- echo 'error: ' $1 $2
- shift 1 ;;
- esac
- done
- mkdir final
- ls *.* | while read img ; do
- echo "$img -> $id.$fmt"
- convert $img -scale $imgsz final/$pfx$id$sfx.$fmt &
- convert $img -scale $tmbsz final/$pfx$id\_t$sfx.$fmt &
- id=$((id+1))
- done
- }
- shot() { # create a screenshot with thumbnail in specified folder
- local PIC="${HOME}/.local/screenshots/%d.%m.%y_%H-%M-%S.jpg"
- scrot -q 90 $PIC
- }
- shotw() { # create a screenshot of a window
- local PIC="${HOME}/.local/screenshots/w_%d.%m.%y_%H-%M-%S.jpg"
- scrot -s -q 90 $PIC
- }
- ## information
- cal() { # print a calender in terminal
- if [[ ! -f /usr/bin/cal ]] ; then
- echo "Please install cal before trying to use it!"
- return
- fi
- if [[ "$#" = "0" ]] ; then
- /usr/bin/cal | egrep -C 40 --color "\<$(date +%e| tr -d ' ')\>"
- echo "Today is `da`"
- else
- cal $@ | egrep -C 40 --color "\<($(date +%B)|$(date +%e | tr -d ' '))\>"
- echo "Today is `da`"
- fi
- }
- ip() { # print my ip
- lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | awk '{ print $4 }' | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g'
- }
- freem() { # show free memory
- free -m | grep 'Mem:' | awk '{print $4}'
- }
- netinfo() { # show network information
- echo "--------------- Network Information ---------------"
- /sbin/ifconfig | awk /'inet addr/ {print $2}'
- /sbin/ifconfig | awk /'Bcast/ {print $3}'
- /sbin/ifconfig | awk /'inet addr/ {print $4}'
- /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
- myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `
- echo "${myip}"
- echo "---------------------------------------------------"
- }
- sysinfo() { # show information about my system
- clear
- num_cpus=`cat /proc/cpuinfo | grep -c "model name"`
- machine_cpu=`cat /proc/cpuinfo | grep -m 1 "model name" | cut -d: -f2`
- machine_mhz=`cat /proc/cpuinfo | grep -m 1 "cpu MHz" | cut -d: -f2`
- machine_cpuinfo=`uname -mp`
- todays_date=`date +"%D %r"`
- machine_uptime=`uptime`
- machine_ram=`cat /proc/meminfo | grep -m 1 "MemTotal:" | cut -d: -f2 | sed 's/^[ \t]*//'`
- machine_video=`lspci | grep -m 1 "VGA" | cut -d: -f3 | sed 's/^[ \t]*//'`
- machine_eth_card=`lspci | grep -m 1 "Ethernet" | cut -d: -f3 | sed 's/^[ \t]*//'`
- machine_audio_controller=`lspci | grep -m 1 "audio" | cut -d: -f3 | sed 's/^[ \t]*//'`
- arch_daemons=`grep "DAEMONS=" /etc/rc.conf `
- last_logins=`last | head`
- eth0info=`ifconfig eth0 | grep "inet addr:" | sed 's/inet addr/Local IP/g' | sed 's/^[ \t]*//;s/[ \t]*$//'`
- echo "ARCH LINUX - Machine Information Script ver .10"
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- echo "DATE: $todays_date MACHINE NAME: $HOSTNAME "
- echo " "
- echo "Eth0: $eth0info"
- echo "ETHERNET CARD: $machine_eth_card"
- echo "CPU INFO: Qty=$num_cpus $machine_cpuinfo"
- echo "VIDEO CARD: $machine_video"
- echo "AUDIO CONTROLLER: $machine_audio_controller"
- echo "RAM INFO: $machine_ram"
- echo " "
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- route
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- echo "DISK USAGE:"
- df -h
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- echo "UPTIME: $machine_uptime"
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- echo "$arch_daemons"
- echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
- }
- vh() { # show basic vi help
- echo "h Move cursor left"
- echo "l Move cursor right"
- echo "A Move cursor to end of line and put in insert mode"
- echo "0 Move cursor to beginning of line"
- echo "i Put into insert mode at current position"
- echo "a Put into insert mode after current position"
- echo "dd Delete line"
- echo "D Delete text after current cursor position"
- echo "p Paste text that was deleted"
- echo "j Move up through history commands"
- echo "k Move down through history commands"
- echo "u Undo"
- }
- weather() { # show the weather for city $1
- declare -a WEATHERARRAY
- WEATHERARRAY=( `lynx -dump "http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+${1}&btnG=Search" | grep -A 5 -m 1 "Weather for" | grep -v "Add to "`)
- echo ${WEATHERARRAY[@]}
- }
- ## archives
- xshow() { # show content of archive but don't unpack
- if [ -f "$1" ]; then
- case "$1" in
- *.tar.bz2) tar -jtf "$1" ;;
- *.tar.gz) tar -ztf "$1" ;;
- *.tar) tar -tf "$1" ;;
- *.tgz) tar -ztf "$1" ;;
- *.zip) unzip -l "$1" ;;
- *.rar) rar vb "$1" ;;
- *) echo "'$1' Error. Please go away" ;;
- esac
- else
- echo "'$1' is not a valid archive"
- fi
- }
- xtar() {
- tar cvf "${1%%/}.tar" "${1%%/}/"
- }
- xtarr() { # same as xtar but remove files/folder after creation of archive
- NAME=`echo $1 | sed -e 's|/||'`
- tar -cf $NAME.tar $NAME
- gzip $NAME.tar
- rm -R $NAME
- }
- xtbz() { # create .tar.bz2 archive
- tar cvjf "${1%%/}.tar.bz2" "${1%%/}/"
- }
- xtgz() { # create .tar.gz archive with optionally $2 being the target directory
- tar cvzf "${1%%/}.tar.gz" "${1%%/}/"
- }
- xtr() { # extract
- if [ -f "$1" ] ; then
- case "$1" in
- *.tar.bz2) mkdir "$2" 2>/dev/null ; tar xjf "$1" -C "$2" ; cd "$2" ;;
- *.tar.gz) mkdir "$2" 2>/dev/null ; tar xzf "$1" -C "$2" ; cd "$2" ;;
- *.bz2) mkdir "$2" 2>/dev/null ; bunzip2 "$1" -C "$2" ; cd "$2" ;;
- *.rar) mkdir "$2" 2>/dev/null ; rar x "$1" -C "$2" ; cd "$2" ;;
- *.gz) mkdir "$2" 2>/dev/null ; gunzip "$1" -C "$2" ; cd "$2" ;;
- *.tar) mkdir "$2" 2>/dev/null ; tar xf "$1" -C "$2" ; cd "$2" ;;
- *.tbz2) mkdir "$2" 2>/dev/null ; tar xjf "$1" -C "$2" ; cd "$2" ;;
- *.tgz) mkdir "$2" 2>/dev/null ; tar xzf "$1" -C "$2" ; cd "$2" ;;
- *.zip) mkdir "$2" 2>/dev/null ; unzip "$1" -C "$2" ; cd "$2" ;;
- *.Z) mkdir "$2" 2>/dev/null ; uncompress "$1" -C "$2" ; cd "$2" ;;
- *.7z) mkdir "$2" 2>/dev/null ; 7z x "$1" -C "$2" ; cd "$2" ;;
- *) echo "Error. Please go away" ;;
- esac
- else
- echo "'$1' is not a valid file"
- fi
- }
Add Comment
Please, Sign In to add comment