Guest User

.zshrc demian

a guest
Apr 25th, 2010
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 57.67 KB | None | 0 0
  1. ## .zshrc demian
  2. #
  3. ####################
  4. # GENERAL SETTINGS #
  5. ####################
  6.  
  7. PATH=$HOME/.bin:$PATH
  8. umask 022
  9.  
  10. ### environment
  11. ## exports
  12. LS_COLORS="no=00:fi=00:rs=0:di=04:ex=00:";
  13. export  CC=/usr/bin/gcc         \
  14.     CORRECT_IGNORE="_*"     \
  15.     DIRSTACKSIZE=20         \
  16.     GREP_OPTIONS=--color=auto   \
  17.     GREP_COLOR="1;36"       \
  18.     HISTFILE="$HOME/.zhistory"  \
  19.     HISTSIZE=5000           \
  20.     LANG="en_US.utf8"       \
  21.     LC_ALL="en_US.utf8"     \
  22.     LC="en_US.utf8"         \
  23.     LESS="-MWi -x4 --shift 5"   \
  24.     LESSHISTFILE="-"        \
  25.     LS_COLORS           \
  26.     MPD_HOST=192.168.0.2        \
  27.     MPD_PORT=6600           \
  28.     SAVEHIST=$HISTSIZE      \
  29.     SHELL=/bin/zsh          \
  30.     TIMEFMT="Real: %E User: %U System: %S Percent: %P Cmd: %J" \
  31.     VISUAL=vim
  32.  
  33. ## setopt (see http://zsh.sourceforge.net/Doc/Release/zsh_15.html)
  34. setopt NO_ALL_EXPORT            \
  35.           ALWAYS_LAST_PROMPT        \
  36.       ALWAYS_TO_END         \
  37.       AUTO_CD           \
  38.        NO_AUTO_CONTINUE         \
  39.       AUTO_LIST         \
  40.        NO_BEEP              \
  41.        NO_BG_NICE           \
  42.           BRACE_CCL         \
  43.       CASE_GLOB         \
  44.       CDABLE_VARS           \
  45.       CHASE_LINKS           \
  46.        NO_CHECK_JOBS            \
  47.           CLOBBER           \
  48.       COMPLETE_IN_WORD      \
  49.       CORRECT_ALL           \
  50.       DOT_GLOB          \
  51.       EXTENDED_GLOB         \
  52.       GLOB              \
  53.       GLOB_COMPLETE         \
  54.       HASH_LIST_ALL         \
  55.       HIST_APPEND           \
  56.        NO_HIST_BEEP         \
  57.       HIST_EXPIRE_DUPS_FIRST    \
  58.       HIST_FIND_NO_DUPS     \
  59.       HIST_IGNORE_ALL_DUPS      \
  60.       HIST_IGNORE_SPACE     \
  61.       HIST_NO_STORE         \
  62.       HIST_NO_FUNCTIONS     \
  63.       HIST_REDUCE_BLANKS        \
  64.       HIST_VERIFY           \
  65.        NO_HUP               \
  66.       IGNORE_EOF            \
  67.       INC_APPEND_HISTORY        \
  68.        NO_LIST_BEEP         \
  69.       LIST_PACKED           \
  70.       LIST_TYPES            \
  71.        NO_LONG_LIST_JOBS        \
  72.       MAGIC_EQUAL_SUBST     \
  73.       MENU_COMPLETE         \
  74.       MULTIOS           \
  75.        NO_NOMATCH           \
  76.        NO_NOTIFY            \
  77.       NUMERIC_GLOB_SORT     \
  78.       NULL_GLOB         \
  79.       PROMPT_VARS           \
  80.        NO_RM_STAR_WAIT          \
  81.       SHARE_HISTORY         \
  82.        NO_SH_WORD_SPLIT         \
  83.        NO_TRANSIENT_RPROMPT
  84.  
  85. ### keybindings
  86. typeset -g -A key
  87. bindkey -e # use emacs keymap (cdp needs it too?)
  88. bindkey "^[OH" beginning-of-line      # home
  89. bindkey "^[OF" end-of-line            # end
  90. bindkey "^[[A"  up-line-or-history    # up
  91. bindkey "^[[D"  backward-char         # left
  92. bindkey "^[[B"  down-line-or-history  # down
  93. bindkey "^[[C"  forward-char          # right
  94. bindkey -M viins "^?" backward-delete-char # traditional backspace
  95. bindkey -M viins "^H" backward-delete-char
  96. bindkey "^[[1;3D" backward-word       # alt + left
  97. bindkey "^[[1;3C" forward-word        # alt + right
  98. bindkey "^[[1;2D" beginning-of-line   # shift + left
  99. bindkey "^[[1;2C" end-of-line         # shift + right
  100. bindkey "^[[3~" delete-char           # del
  101. bindkey "^[[3;3~" delete-word         # alt + delete
  102. bindkey "^[[3;2~" delete-word         # shift + delete
  103. bindkey "_^?" backward-delete-word    # alt + backspace
  104. bindkey "^[" self-insert              # alt + enter
  105. bindkey "^z" undo                     # ctrl + Z
  106. bindkey "^L" push-line                # push current command into a buffer, allows you to do another command then returns to previous command
  107. bindkey ' ' magic-space
  108.  
  109. ## display?
  110. if [ "$DISPLAY" ]; then
  111.   export EDITOR=gvim
  112.   export PICSHOW="q mirage"
  113.  
  114.   alias e="$EDITOR -p"
  115.   alias eb="e $HOME/{.bashtweaks,.bashrc}"             # open bash files
  116.   alias en="e $HOME/.notes"                            # edit notes (also see function note() below)
  117.   alias ez="e $HOME/.zshrc"                            # edit zsh files
  118.   alias m="q medit"                    # run medit quietly and detached from terminal
  119.   alias mb="m $HOME/{.bashtweaks,.bashrc}"             # open bash files
  120.   alias mn="m $HOME/.notes"                            # medit notes (also see function note() below)
  121.   alias mz="m $HOME/.zshrc"                            # medit zsh files
  122.   alias xp='xprop | grep "WM_WINDOW_ROLE\|WM_CLASS" && echo "WM_CLASS(STRING) = \"NAME\", \"CLASS\""' # get xprop CLASS and NAME
  123.  
  124.   ### set window title
  125.   case $TERM in
  126.     *xterm*|rxvt|rxvt-unicode|rxvt-256color|(dt|k|E)term)
  127.         precmd() { print -Pn "\e]0;[%n@%M] [%~]\a" }
  128.         preexec() { print -Pn "\e]0;[%n@%M] [%~] ($1)\a" }
  129.     ;;
  130.     screen)
  131.             precmd() {
  132.             print -Pn "\e]83;title \"$1\"\a"
  133.             print -Pn "\e]0;[%n@%M] [%~]\a"
  134.         }
  135.         preexec() {
  136.             print -Pn "\e]83;title \"$1\"\a"
  137.             print -Pn "\e]0;[%n@%M]%# [%~] ($1)\a"
  138.         }
  139.     ;;
  140.   esac
  141.  
  142.   es() { # use $EDITOR to edit a file but create a backup first
  143.     cp -iv $1 ${1}.backup && $EDITOR $1
  144.   }
  145.   ## toggle vertical terminal size when pressing alt + e
  146.   t() { # toggle vertical terminal size between 24 and 48 lines, gotta wrap this as hotkey
  147.     if ((LINES < 48));then
  148.       printf %b "\033[8;48;80t"
  149.     else
  150.       printf %b "\033[8;24;80t"
  151.     fi
  152.     #sleep .1
  153.     #echo "\$LINES = $LINES"
  154.   }
  155.   zle -N toggle t
  156.   bindkey '^[e' toggle
  157. fi
  158.  
  159.  
  160.  
  161.  
  162. ### completion
  163. ## load
  164. autoload -Uz compinit zargs zmv zcalc
  165. compinit
  166. zmodload zsh/complist
  167.  
  168. if [[ ${ZSH_VERSION//\./} -ge 420 ]] ; then
  169.     autoload -U url-quote-magic
  170.     zle -N self-insert url-quote-magic
  171. fi
  172.  
  173. ## zstyle (from phil!'s prompt)
  174. # options
  175. zstyle ':completion:*:match:*'        original only
  176. zstyle ':completion::prefix-1:*'      completer _complete
  177. zstyle ':completion:predict:*'        completer _complete
  178. zstyle ':completion:incremental:*'    completer _complete _correct
  179. zstyle ':completion:*'            completer _complete _prefix _correct _prefix _match _approximate
  180. # tab, don't annoy me!
  181. zstyle ':completion:*'            insert-tab pending
  182. # menu
  183. zstyle ':completion:*'            menu select=0
  184. zstyle ':completion:*'            select-prompt 'Scrolling active: current selection at %p. Hit BACKSPACE to get out.'
  185. #zstyle ':completion:*'           list-prompt '%SAt %p: Hit TAB for more or BACKSPACE to get out.%s'
  186. # colors
  187. zstyle ':completion:*'            list-colors ${(s.:.)LS_COLORS}
  188. zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
  189. # caching
  190. zstyle ':completion::complete:*'      use-cache on
  191. zstyle ':completion::complete:*'      cache-path ~/.cache/$HOST
  192. # ignore commands i dont have
  193. zstyle ':completion:*:functions'      ignored-patterns '_*'
  194. # dont complete backups as executables
  195. zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~'
  196. # path expansion
  197. zstyle ':completion:*'            expand 'yes'
  198. zstyle ':completion:*'            squeeze-slashes 'yes'
  199. zstyle ':completion::complete:*'      '\\'
  200. # allow forced showing'
  201. zstyle '*' single-ignored show
  202. # case insensitivity, partial matching, substitution
  203. zstyle ':completion:*'            matcher-list 'm:{a-z}={A-Z}' 'm:{A-Z}={a-z}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*'
  204. #zstyle ':completion:*'                    matcher-list 'm:{a-z}={A-Z}'
  205. # group matches and describe
  206. zstyle ':completion:*:matches'        group 'yes'
  207. zstyle ':completion:*'            group-name ''
  208. zstyle ':completion:*:options'        description 'yes'
  209. zstyle ':completion:*:options'        auto-description '%d'
  210. zstyle ':completion:*:descriptions'   format $'\e[01;33m -- %d --\e[0m'
  211. zstyle ':completion:*:messages'       format $'\e[01;35m -- %d --\e[0m'
  212. zstyle ':completion:*:warnings'       format $'\e[01;31m -- No Matches Found --\e[0m'
  213. # prevent re-suggestion
  214. zstyle ':completion:*:rm:*'       ignore-line yes
  215. zstyle ':completion:*:scp:*'          ignore-line yes
  216. zstyle ':completion:*:cp:*'       ignore-line yes
  217. #zstyle ':completion:*:mv:*'          ignore-line yes
  218. zstyle ':completion:*:ls:*'       ignore-line yes
  219. # menu for kill
  220. zstyle ':completion:*:*:kill:*'       menu yes select
  221. zstyle ':completion:*:kill:*'         force-list always
  222. # kill menu extension!
  223. zstyle ':completion:*:processes'      command 'ps -U $(whoami) | sed "/ps/d"'
  224. zstyle ':completion:*:processes'      insert-ids menu yes select
  225. # history
  226. zstyle ':completion:*:history-words'            list false
  227. zstyle ':completion:*:history-words'            menu yes                              # activate menu
  228. zstyle ':completion:*:history-words'            remove-all-dups yes                   # ignore duplicate entries
  229. zstyle ':completion:*:history-words'            stop yes
  230. # remove uninteresting users
  231. zstyle ':completion:*:*:*:users' ignored-patterns          \
  232.     adm alias apache at bin cron cyrus daemon ftp games gdm guest  \
  233.     haldaemon halt mail man messagebus mysql named news nobody nut \
  234.     lp operator portage postfix postgres postmaster qmaild qmaill  \
  235.     qmailp qmailq qmailr qmails shutdown smmsp squid sshd sync     \
  236.     uucp vpopmail xfs
  237. # remove uninteresting hosts
  238. zstyle ':completion:*:*:*:hosts-host' ignored-patterns    \
  239.     '*.*' loopback localhost
  240. zstyle ':completion:*:*:*:hosts-domain' ignored-patterns  \
  241.     '<->.<->.<->.<->' '^*.*' '*@*'
  242. zstyle ':completion:*:*:*:hosts-ipaddr' ignored-patterns  \
  243.     '^<->.<->.<->.<->' '127.0.0.<->'
  244. zstyle -e ':completion:*:(ssh|scp):*' hosts 'reply=(
  245.   ${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) \
  246.   /dev/null)"}%%[# ]*}//,/ }
  247.   )'
  248. # ssh completion
  249. zstyle ':completion:*:scp:*' tag-order \
  250.     files users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
  251. zstyle ':completion:*:scp:*' group-order \
  252.     files all-files users hosts-domain hosts-host hosts-ipaddr
  253. zstyle ':completion:*:ssh:*' tag-order \
  254.     users 'hosts:-host hosts:-domain:domain hosts:-ipaddr"IP\ Address *'
  255. zstyle ':completion:*:ssh:*' group-order \
  256.     hosts-domain hosts-host users hosts-ipaddr
  257. # make completion
  258. compile=(all clean compile disclean install remove uninstall)
  259. compctl -k compile make
  260.  
  261. _force_rehash() { # run rehash on completion
  262.    (( CURRENT == 1 )) && rehash
  263.       return 1 # Because we didn't really complete anything
  264. }
  265.  
  266. # completion for "man" by Gossamer 980827
  267. compctl -f -x 'S[1][2][3][4][5][6][7][8][9]' -k '(1 2 3 4 5 6 7 8 9)' \
  268.   - 'R[[1-9nlo]|[1-9](|[a-z]),^*]' -K 'match-man' \
  269.   - 's[-M],c[-1,-M]' -g '*(-/)' \
  270.   - 's[-P],c[-1,-P]' -c \
  271.   - 's[-S],s[-1,-S]' -k '( )' \
  272.   - 's[-]' -k '(a d f h k t M P)' \
  273.   - 'p[1,-1]' -c + -K 'match-man' \
  274.   -- man
  275.  
  276. ## so useful... need some more customs here.
  277. # command file type detection
  278. compctl -g '*.tar.gz *.tgz *.tar.bz2 *.bz2 *.tar *.tbz2 *.tbz *.gz *.rar *.zip *.7z *.lzo *.xz *.txz *.lzma *.tlz *.Z' + -g '*(-/)' ad al
  279. compctl -g '*.pkg.tar.gz *.pkg.tar.xz' + -g '*' pacman -U
  280. compctl -g '*.pkg.tar.gz *.pkg.tar.xz' + -g '*' sudo pacman -U
  281. compctl -g '*.ebuild' ebuild
  282. compctl -g '*.tex' + -g '*(-/)' latex
  283. compctl -g '*.dvi' + -g '*(-/)' dvipdf dvipdfm
  284. compctl -g '*.java' + -g '*(-/)' javac
  285. compctl -g '*.mp3 *.ogg *.mod *.wav *.avi *.mpg *.mpeg *.wmv' + -g '*(-/)' vlc
  286. compctl -g '*.py' python
  287. compctl -g '*(-/D)' cd
  288. compctl -g '*(-/)' mkdir
  289.  
  290. # command parameter completion
  291. compctl -z fg
  292. compctl -j kill
  293. compctl -j disown
  294. compctl -u chown
  295. compctl -u su
  296. compctl -c sudo
  297. compctl -c which
  298. compctl -c type
  299. compctl -c hash
  300. compctl -c unhash
  301. compctl -o setopt
  302. compctl -o unsetopt
  303. compctl -a alias
  304. compctl -a unalias
  305. compctl -A shift
  306. compctl -v export
  307. compctl -v unset
  308. compctl -v echo
  309. compctl -b bindkey
  310.  
  311. ### system wide functions
  312. ## backup
  313. bu() { # create backup in $HOME/.backup
  314.   bakdir="$HOME/.backup"
  315.   [ ! -d "$bakdir" ] && mkdir -p -m 700 "$bakdir"
  316.   for f in "$@"; do
  317.     f="`echo "$f" | sed 's!/\+$!!'`"   # strip trailing slashes
  318.       command cp -ai "$f" "$HOME/.backup/$f-`date +'%Y%m%d%H%M'.bak`"
  319.   done
  320. }
  321. buh() { # create backup here
  322.   for f in "$@"; do
  323.     f="`echo "$f" | sed 's!/\+$!!'`"   # strip trailing slashes
  324.       command cp -ai "$f" "$f-`date +'%Y%m%d%H%M'.bak`"
  325.   done
  326. }
  327. bur() { # create recursive backup in $HOME/.backup maintaining file system structure
  328.   if [ "`dirname $1`" == "." ]; then
  329.       mkdir -p $HOME/.backup/`pwd`;
  330.       cp -r "$1" $HOME/.backup/`pwd`/$1-`date +%Y%m%d%H%M`.bak;
  331.   else
  332.       mkdir -p $HOME/.backup/`dirname $*`;
  333.       cp -r "$1" $HOME/.backup/$1-`date +%Y%m%d%H%M`.bak;
  334.   fi
  335. }
  336.  
  337. ## move in folder structure like a pro
  338. alias b="popd"
  339. alias c="cd"
  340.  
  341. setopt    AUTO_PUSHD            \
  342.       PUSHD_IGNORE_DUPS     \
  343.       PUSHD_SILENT          \
  344.       PUSHD_TO_HOME
  345.  
  346. cd() { # always ls when cd'ing, also use pushd so i can retrace my steps via popd
  347.   builtin pushd $@ && ls --color=always -hF
  348. }
  349.  
  350. cdp() { # change directory (Author W.Friebel friebel@ifh.de 13/04/95)
  351. TRAPINT() {
  352.   bindkey "^M" accept-line
  353.   setopt +B
  354.   trap - INT
  355.   builtin let "$1 > 0" && return $[128+$1]
  356. }
  357. setopt -B
  358. bindkey -s "^M" "^X^W"
  359. bindkey "^[k" kill-region
  360. # Select_Key definition:
  361. # to column 2; to begin of line; insert  cd ;
  362. # to begin of line; mark position; to begin of buffer; delete up to mark
  363. # to end of line; mark position; to end of buffer; to end of line
  364. # delete up to mark; put cd command into input buffer and execute
  365. bindkey -s "^X^W" "^[2^[|^A cd ^A^@^[<^[k^E^@^[>^E^[k^[a^X^K"
  366. cdp_var=`builtin print "### Select (and Edit) directory, Enter to accept it, ^C to quit ###"
  367. builtin print -l \`dirs \``
  368. vared cdp_var
  369. bindkey "^M" accept-line
  370. setopt +B
  371. eval $cdp_var
  372. }
  373.  
  374. ## system wide functions
  375. # daemon control
  376. cdiff() { # create a diff
  377.   diff -udrP "$1" "$2" > diff.$(date "+%Y-%m-%d")."$1"
  378. }
  379. dreload() { # reload a daemon
  380.   if [ "$UID" = 0 ];then
  381.     for arg in $*; do
  382.       /etc/rc.d/$arg reload
  383.     done
  384.   else
  385.     for arg in $*; do
  386.       sudo /etc/rc.d/$arg reload
  387.     done
  388.   fi  
  389. }
  390. drestart() { # restart a daemon
  391.   if [ "$UID" = 0 ];then
  392.     for arg in $*; do
  393.       /etc/rc.d/$arg restart
  394.     done
  395.   else
  396.     for arg in $*; do
  397.       sudo /etc/rc.d/$arg restart
  398.     done
  399.   fi
  400. }
  401. dstart() { # start a daemon
  402.   if [ "$UID" = 0 ];then
  403.     for arg in $*; do
  404.       /etc/rc.d/$arg start
  405.     done
  406.   else
  407.     for arg in $*; do
  408.       sudo /etc/rc.d/$arg start
  409.     done  
  410.   fi
  411. }
  412. dstat() { # show status of a daemon (if possible)
  413.   if [ "$UID" = 0 ];then
  414.     for arg in $*; do
  415.       /etc/rc.d/$arg status
  416.     done
  417.   else
  418.     for arg in $*; do
  419.       sudo /etc/rc.d/$arg status
  420.     done  
  421.   fi
  422. }
  423. dstop() { # stop a daemon
  424.   if [ "$UID" = 0 ];then
  425.     for arg in $*; do
  426.       /etc/rc.d/$arg stop
  427.     done
  428.   else
  429.     for arg in $*; do
  430.       sudo /etc/rc.d/$arg stop
  431.     done  
  432.   fi
  433. }
  434. # file operations
  435. dirsize() { # show size of all directories in current working directory
  436.   du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
  437.   egrep '^ *[0-9.]*[MG]' | sort -n > /tmp/list
  438.   egrep '^ *[0-9.]*M' /tmp/list
  439.   egrep '^ *[0-9.]*G' /tmp/list
  440.   rm /tmp/list
  441. }
  442. f() { # find a file
  443.   find 2>/dev/null | grep -is "$1"
  444. }
  445. fc() { # search content
  446.       if [ $# -eq 0 ]; then
  447.               echo "findcontent: No arguments entered."; return 1
  448.       else
  449.              # "{.[a-zA-Z],}*" instead of "." makes the output cleaner
  450.              find {.[a-zA-Z],}* -type f 2>/dev/null | xargs grep -is --color=always -n "$@"
  451.       fi
  452. }
  453. fcd() { # search content and specify the path to look
  454.       if [ $# -eq 0 ]; then
  455.         echo "findcontent: No arguments entered."; return 1
  456.       else
  457.         # "{.[a-zA-Z],}*" instead of "." makes the output cleaner
  458.         find "$1" -type f 2>/dev/null | xargs grep -is --color=always -n "$2"
  459.       fi
  460. }
  461. fd() { # specify where find should look
  462.   find "$1" 2>/dev/null | grep -is "$2"
  463. }
  464. ff() { # find a file in my filesystem
  465.   find / 2>/dev/null | grep -is "$1"
  466. }
  467. fp() { # find in $PATH
  468.   find $(sed 's/:/ /g' <<<$PATH) 2>/dev/null | grep --color $1
  469. }
  470. sanitize() { # change mode and users of files to safe default
  471.   chmod -R u=rwX,go=rX "$@"
  472.   chown -R ${USER}:users "$@"
  473. }
  474. vs() { # use vim to edit a file but create a backup first
  475.   cp -iv $1 ${1}.backup && $VISUAL $1
  476. }
  477. wgp() { # paste file at paste.pocoo.org
  478.     wgetpaste "$@"
  479. }
  480.  
  481. ### system wide aliases
  482. ## globals and suffixes
  483. alias -s {conf,java,txt,TXT,README,PKGBUILD}=$VISUAL
  484. alias -g G="| grep"
  485. alias -g M="| most"
  486. alias -g X="| xargs"
  487. alias -g H="| head"
  488. alias -g T="| tail"
  489. alias -g S="| sort"
  490. alias -g SU="|sort -u"
  491. alias -g SN="|sort -n"
  492. alias -g SNR="|sort -nr"
  493. alias -g W="| wc -l"
  494. alias -g N="&>/dev/null"
  495. alias -g 1N="1>/dev/null"
  496. alias -g 2N="2>/dev/null"
  497.  
  498. ## mpd
  499. alias cmpd="ncmpc --host=192.168.0.2"
  500. alias lock="pause && slock && play"
  501. alias mt="amixer -q set Master toggle"
  502. alias mvol="mpc --no-status volume $1"
  503. alias nxt="mpc --no-status next"
  504. alias pause="mpc --no-status pause"
  505. alias pl="mpc --no-status playlist"
  506. alias play="mpc --no-status play"
  507. alias rnd="mpc random G random"
  508. alias rpt="mpc repeat G repeat"
  509. alias shfl="mpc --no-status shuffle"
  510. alias sta="mpc status"
  511. alias svol="amixer set Master $1"
  512. alias tog="mpc --no-status toggle"
  513.  
  514. ## ls
  515. alias ls="ls --color=always -hF"         # classify and human-readable
  516. alias l=ls                               # ls
  517. alias ll="ls -l"                         # list detailed with human-readable sizes
  518. alias lw="ls -1"                         # windows-style list
  519. alias la="ll -A"                         # list all but not . and ..
  520. alias lat="llt -A"                       # lt with -A
  521. alias lax="llx -A"                       # lx with -A
  522. alias lay="lly -A"                       # ly with -A
  523. alias llt="ll -rt"                       # sort by modification time
  524. alias llx="ll -BX"                       # sort by extension
  525. alias lly="ll -rS"                       # sort by size
  526.  
  527. alias lbig="ls -lSh *(.) | head"         # list biggest
  528. alias lnew="ll -rt *(.) | tail"          # list newest
  529. alias lold="ll -rt *(.) | head"          # list oldest
  530. alias lsmall="ls -lSh *(.) | head"       # list smallest
  531.  
  532. alias lsb="la $HOME/.backup"             # list content of .backup
  533. alias lscr="ll $HOME/.local/screenshots" # list screenshots
  534. alias lsd="ll /var/run/daemons"          # list running daemons
  535. alias lsdev="ls /dev | grep sd"          # list sata devices
  536. alias lsuuid="ls -l /dev/disk/by-uuid/"  # list disks by uuid
  537. alias lst="ll /tmp"                      # list temporary directory
  538.  
  539. # very cool zsh aliases by elasticdog
  540. alias lh="ls -d .*"          # list hidden files/directories
  541. alias lhd="ls -d .*(-/N)"        # list hidden directories
  542. alias lhf="ls .*(-.N)"           # list hidden files
  543. alias llh="ls -lhd .*"           # list details of hidden files/directories
  544. alias llhd="ls -lhd .*(-/N)"         # list details of hidden directories
  545. alias llhf="ls -lh .*(-.N)"      # list details of hidden files
  546. alias le="ls -d *(-/DN^F)"       # list all empty directories
  547. alias ler="ls -d **/*(-/DN^F)"       # list all empty directories recursively
  548. alias lle="ls -ld *(-/DN^F)"         # list details of all empty directories
  549. alias ller="ls -lhd **/*(-/DN^F)"    # list details of all empty directories recursively
  550.  
  551. ## these pairs show exactly the same
  552. ## i'll have to look into these
  553. alias ld="ls -d *(-/N)"          # list visible directories
  554. alias lf="ls *(-.N)"             # list visible files
  555. alias lld="ls -lhd *(-/N)"       # list details of visible directories
  556. alias llf="ls -lh *(-.N)"        # list details of visible files
  557. alias lad="ls -d *(-/DN)"        # list all directories
  558. alias laf="ls -A *(-.DN)"        # list all files
  559. alias llad="ls -lhd *(-/DN)"         # list details of all directories
  560. alias llaf="ls -lhA *(-.DN)"         # list details of all files
  561.  
  562. ## rm
  563. alias rm="rm -Iv"                        # secure remove but less annoying than -i
  564. alias rmr="rm -r"                        # including folders
  565.  
  566. ## short ones
  567. alias a=cat
  568. # b: popd
  569. # c: pushd
  570. alias d=pwd
  571. #f: find in wd
  572. alias g=grep
  573. alias h=history
  574. alias k="kill"
  575. alias n=note
  576. #t: toggle terminal size
  577. #q: run quietly and disowned
  578. alias v="$VISUAL -p"
  579. alias x=exit
  580. #y: yaourt
  581.  
  582. #################
  583. # ROOT SETTINGS #
  584. #################
  585.  
  586. if [[ $UID == 0 ]]; then
  587.   # close root shell after n seconds for security reasons
  588.   export TMOUT=180
  589.  
  590.   # root prompt
  591.   PROMPT=$'%{\e[0;31m%} #%{\e[0m%} '
  592.   RPROMPT='[%~] %*'
  593.  
  594.   # root aliases
  595.   alias hlt="shutdown -h now"                # halt now
  596.   alias hltin="shutdown -h"                  # halt in n minutes
  597.   alias mnt="mount"                          # mount
  598.   alias rbt="shutdown -r now"                # reboot now
  599.   alias rbtin="shutdown -r"                  # reboot in n minutes
  600.   alias showlog="tail -f /var/log/everything.log"
  601.   #alias sublimation="pacman -R $(pacman -Qq | grep -v "$(pacman -Qqg base)")" # careful! deletes every package except for those in the base group
  602.   alias suspend="pm-suspend"                 # suspend
  603.   alias umnt="umount"                        # umount
  604.  
  605.   if [ $HOST = 13 ]; then
  606.     fan() { # control fan
  607.       if [ $# = 0 ];then
  608.         cat /proc/acpi/ibm/fan
  609.       elif [ $1 = off ];then
  610.         echo disable > /proc/acpi/ibm/fan
  611.       elif [ $1 = on ];then
  612.         echo level auto > /proc/acpi/ibm/fan
  613.       elif [ $1 = 1 ];then
  614.         echo level 1 > /proc/acpi/ibm/fan
  615.       else
  616.         echo "$@" > /proc/acpi/ibm/fan
  617.       fi
  618.     }
  619.   fi
  620.  
  621.   lamb() { # beep the children's song
  622.     beep -f 10
  623.       echo "Marry Had A Little Lamb"
  624.         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
  625.       echo "Little Lamb, Little Lamb"
  626.         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
  627.       echo "Marry Had A Little Lamb"
  628.         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
  629.       echo "Whose Fleece Was White As Snow"
  630.         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
  631.   }
  632.  
  633.   setup() { # run as root on a fresh system to install base and gui packages and create user
  634.    
  635.   echo -n "Is your network up and running? (y/n) "
  636.   if read -q; then
  637.     echo "Good. Proceeding."
  638.   else
  639.     echo "You'll need internet access."
  640.     echo "Please configure your network before calling this script again."
  641.     return 0
  642.   fi
  643.    
  644.   echo -n "Did you configure pacman.conf to include [archlinuxfr]? "
  645.   if read -q; then
  646.     echo "Good. Proceeding."
  647.   else
  648.     echo "Don't worry. I'll do it for you."
  649.     echo " " >> /etc/pacman.conf
  650.     echo "[archlinuxfr]" >> /etc/pacman.conf
  651.       if [[ `uname --machine` = i686 ]];then
  652.         echo "Server = http://repo.archlinux.fr/i686" >> /etc/pacman.conf
  653.     echo "Your pacman.conf is now updated to include the 32bit repository of archlinuxfr."
  654.       elif [[ `uname --machine` = x86_64 ]];then
  655.     echo "Server = http://repo.archlinux.fr/x86_64" >> /etc/pacman.conf
  656.     echo "Your pacman.conf is now updated to include the 64bit repository of archlinuxfr."
  657.       else
  658.     echo "Sorry, but i can't read the system architecture."
  659.     echo "Please configure pacman.conf manually."
  660.     echo "Exiting now."
  661.     return 0
  662.       fi
  663.   fi
  664.    
  665.   echo -n "Are you using a fast and up-to-date mirror? "
  666.   if read -q; then
  667.     echo "Good. Proceeding."
  668.       echo -n "Did you sync the mirrorlist yet? "
  669.       read answer
  670.       case "$answer" in
  671.         yes|y|'') echo "Good. Proceeding."
  672.           ;;
  673.     no|n)     echo "Okay. Let's do it now."
  674.                   pacman -Syy
  675.                   echo "Done. Proceeding with setup."
  676.           ;;
  677.       esac
  678.   else
  679.     echo "NP. Doing it for you. I may need input though."
  680.     echo "Checking if reflector is installed."
  681.     if [[ `pacman -Qsl | grep reflector | wc -l` = 0 ]];then
  682.       echo "Not installed. Downloading reflector."
  683.       pacman -Sy reflector
  684.     else
  685.       echo "Good. Reflector is installed."
  686.     fi
  687.     echo "Updating your mirrorlist now."
  688.     reflector -l 8 -r -o /etc/pacman.d/mirrorlist
  689.     echo "Your mirrorlist should now be updated."
  690.     echo "Proceeding."
  691.   fi
  692.  
  693.   echo -n "Download and install Base and GUI now? (base/both/none) "
  694.   read answer
  695.   case "$answer" in
  696.     both) echo "Both basic system and gui packages will now be installed and downloaded."
  697.           echo "No input needed for the next ~30 minutes. Go do some work."
  698.       pacman -S alsa-utils acpid pm-utils cpufrequtils nfs-utils rpcbind rsync tree  \
  699.             calc bc dosfstools ntfsprogs abs cups pmount samba openssh  ntfs-3g  \
  700.             ethtool lm_sensors stress reflector                  \
  701.             lzop unzip rar p7zip unrar zip xz-utils unace            \
  702.             zsh grc cowsay fortune-mod vim htop screen               \
  703.                     irssi wgetpaste scrot curl clamav powertop laptop-mode-tools slock   \
  704.             mpc moc imagemagick yaourt                       \
  705.             xorg xf86-input-evdev xf86-video-intel               \
  706.             openbox openbox-themes obconf obmenu                 \
  707.             gamin transset-df gxmessage xdg-user-dirs xcompmgr           \
  708.             ttf-dejavu ttf-ms-fonts ttf-bitstream-vera               \
  709.             terminal galculator gvim feh pcmanfm gmrun medit xarchiver epdfview  \
  710.             mirage conky sonata gmpc firefox thunderbird flashplugin vlc
  711.       echo "Delete libxft and cairo to replace them with lcd packages later on."
  712.       pacman -Rd libxft cairo          
  713.       echo "Some more packages from the AUR."
  714.       yaourt -S fortune-mod-tbbt fortune-mod-montypython fortune-mod-himym       \
  715.             fortune-mod-chucknorris tupac zsh-tupac zsh-yaourt zsh-lovers    \
  716.             fontconfig-lcd cairo-lcd                         \
  717.             aurvote firebrand thunderbrand sir
  718.       pacman -S libxft-lcd
  719.       ;;
  720.     base) echo "Only basic system packages will now be downloaded and installed."
  721.       echo "Downloading basic packages"
  722.       pacman -S alsa-utils acpid pm-utils cpufrequtils nfs-utils rpcbind rsync tree  \
  723.               calc bc dosfstools ntfsprogs abs cups pmount samba openssh    ntfs-3g  \
  724.           ethtool lm_sensors stress reflector                    \
  725.           lzop unzip rar p7zip unrar zip xz-utils unace              \
  726.           zsh grc cowsay fortune-mod vim htop screen                 \
  727.                   irssi wgetpaste scrot curl clamav powertop laptop-mode-tools slock     \
  728.           mpc moc yaourt
  729.      echo "Some fun stuff from the AUR."
  730.      yaourt -Sy --aur fortune-mod-tbbt fortune-mod-montypython fortune-mod-himym     \
  731.               fortune-mod-chucknorris tupac zsh-tupac zsh-yaourt zsh-lovers
  732.      ;;
  733.     none) echo "Skipping download and installation."
  734.      ;;
  735.   esac
  736.    
  737.   echo -n "Setup User now? "
  738.     if read -q; then
  739.       echo "Preparing to create user."
  740.         echo -n "Setup demian or slave? "
  741.     read answer
  742.     case "$answer" in
  743.       demian|d|1) echo "Proceeding for demian."
  744.               echo "Creating user demian, his password and some directories."
  745.               useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/zsh demian
  746.               echo "Please specify a password:"
  747.               passwd demian
  748.               echo "Creating directories in /media:"
  749.               mkdir -v /media/share /media/daten
  750.               echo "Downloading some last packages:"
  751.               yaourt -S tp_smapi phc-intel
  752.               echo "System is installed and ready to configure."
  753.               ;;
  754.        slave|s|2) echo "Proceeding for slave."
  755.               echo "Creating user slave, his password and some directories"
  756.               useradd -m -G users,audio,lp,optical,storage,video,wheel,power -s /bin/zsh slave
  757.               echo "Please specify a password:"
  758.               passwd slave
  759.               echo "Creating directories in /media:"
  760.               mkdir -v /media/movies /media/music /media/series /media/share /media/usbhdd
  761.               echo "Downloading some last packages:"
  762.               pacman -S lighttpd fcgi php php-cgi mpd rtorrent
  763.               yaourt -S phc-intel eaccelerator
  764.               echo "System is installed and ready to configure."
  765.               ;;
  766.           esac
  767.   else
  768.     echo "Skipping user creation. Setup is done."
  769.   fi
  770.   }
  771.  
  772.   sysbak () { # system backup to $HOME/backup-$DATE.tar.bz2
  773.     DATE=$(date +%Y-%m-%d-%H%M%S)
  774.     BACKUP_DIR="$HOME"
  775.     SOURCE=(/boot/grub/menu.lst /etc/conf.d /etc/exports /etc/fuse.conf /etc/clamav/clamd.conf /etc/lighttpd/lighttpd.conf /etc/php/php.ini /etc/rc.d/rtorrent /etc/sudoers /etc/inittab /etc/acpi/events/power /etc/mkinit* /etc/modprobe.d/modprobe.conf /etc/ssh/sshd_config /etc/rc.conf /etc/rc.local /etc/rc.sys* /etc/issu* /etc/hosts* /etc/resolv.conf /etc/pacman.conf /etc/pacman.d/mirrorlist /etc/fstab /etc/mpd.conf /etc/samba/smb.conf /etc/hal/fdi/policy/*.fdi /etc/laptop-mode /etc/xdg/user-dirs.defaults /home/slave/.rtorrent.rc /home/slave/.conkyrc /home/slave/.xinitrc /proc/config.gz /root /srv/http /usr/share/vlc/http/.hosts /usr/share/pcmanfm/mount.rules /var/lib/mpd/playlists)
  776.     tar -cjpf $BACKUP_DIR/sysbak-$DATE.tar.bz2 $SOURCE
  777.   }
  778.  
  779.   # root stops parsing this file here
  780.   return 0
  781. fi
  782.  
  783. #################
  784. # USER SETTINGS #
  785. #################
  786.  
  787. ### general settings
  788. ## user prompt
  789. PROMPT=" > "
  790. RPROMPT="[%~] %*"
  791.  
  792. ## greeting
  793. dir="/usr/share/cows"
  794. file=`/bin/ls -1 "$dir" | sort --random-sort | head -1`
  795. cow="$(echo "$file" | sed -e "s/\.cow//")"
  796. fortune | cowsay -W 75 -f $cow
  797.  
  798. if [ "$DISPLAY" ]; then
  799.   ## exports
  800.   export BROWSER=.bin/firefox           \
  801.      EXCEL=oocalc               \
  802.      OFFICE=oowriter            \
  803.      PDF="q epdfview"           \
  804.          VIDEO=vlc              \
  805.      XAUTHORITY="$HOME/.Xauthority"     \
  806.      XDG_CACHE_HOME="$HOME/.cache"      \
  807.      XDG_CONFIG_DIR="$HOME/.config"     \
  808.      XDG_CONFIG_DIRS="$HOME/.config:/etc"   \
  809.      XDG_DATA_HOME="$HOME/.config/share"    \
  810.      XDG_DESKTOP_DIR="$HOME"        \
  811.      XDG_DOCUMENTS_DIR="$HOME/doc"      \
  812.      XDG_DOWNLOAD_DIR="$HOME/down"      \
  813.      XDG_MUSIC_DIR="$HOME"          \
  814.      XDG_PICTURES_DIR="$HOME/pics"      \
  815.      XDG_PUBLICSHARE_DIR="$HOME"        \
  816.      XDG_TEMPLATES_DIR="$HOME"      \
  817.      XDG_VIDEOS_DIR="$HOME"
  818.  
  819.   ## suffixes
  820.   alias -s {PDF,pdf}=$PDF
  821.   alias -s {docx,DOCX,doc,DOC,odt,ODT,sxw}=$OFFICE
  822.   alias -s {ods,xls}=$EXCEL
  823.   alias -s {jpg,JPG,jpeg,JPEG,png,PNG,gif,GIF}=$PICSHOW
  824.   alias -s xcf="q gimp"
  825.   alias -s svg="q inkscape"
  826.   alias -s {MP3,mp3,ogg,wav,WAV,flac,FLAC,mpg,mpeg,avi,AVI,ogm,wmv,m4v,mp4,mov,mkv,MKV}=$VIDEO
  827.   alias -s {html,htm,php,url,org,de,com,net,uk}=$BROWSER
  828.  
  829.   ## various
  830.   alias eo="e $HOME/.config/openbox/{rc.xml,menu.xml}" # edit openbox files
  831.   alias firefox="q .bin/firefox"                       # firefox
  832.   alias mo="m $HOME/.config/openbox/{rc.xml,menu.xml}" # medit openbox files
  833.   alias pc="q mirage"                                  # start mirage disowned with no stdout
  834.   alias pf="q epdfview"                                # start epdfview disowned with no stdout
  835.   alias regex="pc $HOME/.local/regex.png"              # show regex cheatsheet
  836.   alias se="sudo e"                                    # $EDITOR
  837.   alias session="q session"                            # .bin/session
  838.   alias sm="sudo m"                                    # medit
  839.   alias vlc="q vlc"                                    # run vlc quietly
  840.   alias vo="v $HOME/.config/openbox/{rc.xml,menu.xml}" # visual edit openbox files
  841.  
  842.   ## functions
  843.   ses() { # es but with sudo privileges
  844.     sudo cp -iv "$1" ${1}.backup && sudo $EDITOR "$1"
  845.   }
  846. fi
  847.  
  848. ## which host?   
  849. if [ $HOST = 2 ]; then
  850.   alias cdi="cd /media/music/incoming"          # change directory to incoming
  851.   alias cdmo="cd /media/movies"             # change directory to movies  
  852.   alias cdmu="cd /media/music"              # change directory to music
  853.   alias cds="cd /media/series"              # change directory to series
  854.   alias cdu="cd /media/usbhdd"              # change directory to usbhdd
  855.   alias lsi="lx /media/music/incoming"          # list incoming
  856.   alias mntu="mount /media/usbhdd"          # mount usbhdd
  857. elif [ $HOST = 13 ]; then
  858.   alias bats="c /proc/acpi/battery/BAT0/state"          # show battery state
  859.   alias cdd="cd /media/daten/down"                      # change directory to incoming
  860.   alias mnth="mount 192.168.0.2:/home/slave $HOME/.shares/home ; cd $HOME/.shares/home" # mount NFS home
  861.   alias mntm="mount 192.168.0.2:/media $HOME/.shares/media ; cd $HOME/.shares/media"    # mount NFS media
  862.   alias ssh2="ssh slave@192.168.0.2"                    # ssh into 2
  863.   alias umnth="sudo umount.nfs 192.168.0.2:/home/slave" # umount nfs home
  864.   alias umntm="sudo umount.nfs 192.168.0.2:/media"  # umount nfs media
  865.   alias wc="wicd-curses"                                # wicd
  866.   alias wup="ifconfig wlan0 up"                         # ifconfig
  867. fi
  868.  
  869. ### aliases
  870. ## ps
  871. alias pas="ps -efH"                              # all processes, in hierarchy and full-format listing
  872. alias pac0="ps aux | sort -k 3,3 | tail "        # list processes by cpu usage
  873. alias pac1='ps -eo pcpu,nice,stat,time,pid,cmd --sort=-pcpu,-time | sed "/^ 0.0 /d"'
  874. alias pag="ps aux | grep -v grep | grep"         # search process
  875. 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//'"
  876. alias par0="ps aux | sort -k 4,4 | tail "        # list processes by memory usage
  877. alias par1='ps -eo rss,vsz,pid,cmd --sort=-rss,-vsz | awk "{ if (\$1 > 10000) print }"'
  878. alias pau="ps uxU $1"                            # list processes by user
  879.  
  880. ## cd
  881. alias cdb="cd $HOME/.backup"             # change directory to $HOME/.backup
  882. alias cdbin="cd $HOME/.bin"                      # change directory to .bin
  883. alias cdt="cd /tmp"                              # change directory to /tmp  
  884. alias cd.s="cd $HOME/.shares"                    # change directory to .shares
  885. alias cdm="cd /media"                            # change directory to media
  886. alias cdscr="cd $HOME/.local/screenshots"        # change directory to screenshots
  887. alias cdsh="cd /media/share"                     # change directory to share
  888. alias cdwp="cd $HOME/.local/wallpapers"          # change directory to wallpapers
  889.  
  890. ## chown, chmod
  891. alias 000="chmod 000"
  892. alias 644="chmod 644"
  893. alias 755="chmod 755"
  894. alias cm="chmod"                 # chmod
  895. alias chr="chmod a+r"                            # add read permissions for all users
  896. alias chw="chmod a+w"                            # add write permissions for all users
  897. alias co="chown"                 # chown
  898. alias cx="chmod a+x"                             # make file executable for everyone
  899.  
  900. ## system
  901. alias ..="cd ../"                                # move up one directory
  902. alias ...="cd ../../"                            # move up two directories
  903. alias ....="cd ../../../"                        # move up three directories
  904. alias cl="clear"                                 # clear screen    
  905. alias clam="clamscan --bell -i"                  # scan a file
  906. alias clami="clam -r /media/music/incoming"  # scan incoming files
  907. alias clamt="clam -r /tmp"           # scan /tmp
  908. alias cpr="cp -r"                    # copy recursively
  909. alias cpv="rsync -P"                             # use rsync as cp alternative due to more information
  910. alias da="date '+%A, %d.%m.%Y, %T'"              # Wednesday, 21.04.2010, 14:22:25
  911. alias dat="date '+%A, %B %d, %Y [%T]'"           # Thursday, April 15, 2010 [16:27:42]
  912. alias df="df -h"                                 # file system disk space usage in human-readable sizes
  913. alias du="du -hc"                                # disk space usage in human-readable sizes
  914. alias du1="du --max-depth=1"                     # look no deeper than one directory level
  915. alias dus="du -s"                                # disk space usage in human-readable sizes
  916. alias duchs="du -chs * 2>/dev/null |sort -rn |head -11" # disk hog
  917. alias eg="egrep --color=auto"                    # colourized egrep
  918. alias egrep="egrep --color=auto"                 # colourized egrep
  919. alias free="free -m"                             # show sizes in MB
  920. alias hist="history | grep"                      # search cmd history
  921. alias ka="killall"                               # killall
  922. alias less="less -iF"                            # less with ignore-case and quit-if-one-screen enabled
  923. alias make="time make"                           # time make
  924. alias makepkg="time makepkg"                     # time makepkg
  925. alias md="mkdir -pv"                             # create parents and verbose output
  926. alias mtd='tdir=`mktemp -d` && cd $tdir'         # make temp dir and cd into it
  927. alias more="less"                                # less is more
  928. alias nano="vim"                                 # .
  929. alias ns="netstat -alnp --protocol=inet | grep -v CLOSE_WAIT | cut -c-6,21-94 | tail"
  930. alias nsw="sudo watch -n 3 -d -t netstat -vantp" # watch incoming connections
  931. alias openports="netstat --all --numeric --programs --inet"
  932. alias parts="cat /proc/partitions"               # show partitions
  933. alias pk="pkill"                                 # pkill
  934. alias pm="pmount"                                # pmount
  935. alias pum="pumount"                              # pumount
  936. alias pw='echo `< /dev/urandom tr -cd "[:graph:]" | head -c8`' # create secure password
  937. alias rd="rmdir"                 # remove directory
  938. alias rsynn="rsync -r -n -t -p -o -g -v --progress --delete -l"
  939. alias trace="traceroute -I"                      # tracerout using icmp echo instead of udp datagrams
  940. alias tree="tree -C"                             # colorize tree output
  941. alias vb="v $HOME/{.bashtweaks,.bashrc}"         # visual edit bash files
  942. alias vn="v $HOME/.notes"                        # visual edit notes (also see function note() below)
  943. alias vz="v $HOME/.zshrc"                        # visual edit zsh files
  944.  
  945. ## .bin
  946. #alias archinfo="archinfo"       # shows DE/WM information
  947. alias bat="bat -b0"              # battery information
  948. #alias firefox="firefox"         # wrapper for firefox
  949. #alias mod="mod"                 # shows required kernel modules
  950. #alias pclean="pclean"           # clean pacman database
  951. #alias pfree="pfree"             # shows files that are not owned by any package
  952. #alias psizee="psizee"           # sorts all installed packages by size
  953. #alias pwcat="pwcat"             # show power setting information (needs redo)
  954. #alias pwdo="pwdo"               # execute power settings (needs redo)
  955. #alias q="q"                     # run program quietly and detached from terminal
  956. #alias read_msr="read_msr"       # used to verify undervolting controls
  957. #alias rndwp="rndwp"             # random wallpaper!
  958. #alias session="session"         # used with gxmessage to create popup for session control
  959. #alias temp="temp"               # show temperatures (needs redo)
  960.  
  961. ## colorize
  962. if which grc &>/dev/null; then
  963.   alias .cl="grc -es --colour=auto"
  964.   alias configure=".cl ./configure"
  965.   alias diff=".cl diff"
  966.   alias make=".cl make"
  967.   alias gcc=".cl gcc"
  968.   alias g++=".cl g++"
  969.   #alias as=".cl as"
  970.   #alias gas=".cl gas"
  971.   #alias ld=".cl ld"
  972.   alias netstat=".cl netstat"
  973.   alias ping=".cl ping -c 5"
  974.   alias traceroute=".cl traceroute"
  975. fi
  976.  
  977. ## user
  978. alias irc="irssi -n mikar"               # irc
  979. alias or="openbox --reconfigure"                     # reconfigure openbox
  980. 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.
  981. alias sls="screen -ls"                               # lists pid.tty.host strings
  982. alias ss="screen -S $1"                              # start session specifying a name
  983.  
  984. ## pacman
  985. alias pqg="pacman-color -Qg | sed 's/ .*//' | sort | uniq" # list groups of installed packages
  986. alias psl="pacman-color -Sl | grep -i "         # search pacman-color database for string
  987. #alias pfree="pfree"                            # create list of all files not owned by any package
  988. #alias psizea="psizea"                          # list all installed packages and sort by size
  989. #alias psizee="psizee"                          # list explicitly installed packages and sort by si
  990.  
  991. ## tupac (wrapper for yaourt and pacman with local caching)
  992. alias y="tupac"                  # tupac
  993. alias yq="tupac -Q | grep -i"    # query
  994. alias yqe="tupac -Qe"            # show explicitly installed packages
  995. alias yqi="tupac -Qi"            # show information about an installed package
  996. alias yql="tupac -Ql"            # show files installed by a package
  997. alias yqo="tupac -Qo"            # search for package that owns the file
  998. alias yqs="tupac -Qs"            # search installed packages
  999. alias yr="tupac -R"              # remove
  1000. alias yrd="tupac -Rd"            # remove omitting dependencies
  1001. alias yrs="tupac -Rs"            # remove including unused dependencies
  1002. alias ys="tupac -S"              # download and install
  1003. alias ysb="tupac -Sb"            # builds the targets from source
  1004. alias ysc="tupac -Sc"            # clean those packages from cage that are no longer installed
  1005. alias yscc="tupac -Scc"          # clean the whole cache directory
  1006. alias ysf="tupac -Sf"            # force (re-)installation
  1007. alias ysi="tupac -Si"            # show information about a non-local package
  1008. alias ysl="tupac -Sl | grep -i " # list all packages in specified repository
  1009. alias yss="tupac -Ss"            # query database
  1010. alias ysw="tupac -Sw"            # download but don't install
  1011. alias ysu="tupac -Su --aur"      # upgrade all aur packages
  1012. alias ysy="tupac -Sy --aur"      # sync refresh
  1013. alias ysyu="tupac -Syu --aur"    # sync refresh sys update + aur
  1014. alias ysyy="tupac -Syy --aur"    # force sync refresh + aur
  1015. alias ysyyu="tupac -Syyu --aur"  # force sync refresh and update + aur
  1016. alias yu="tupac -U"              # install local package
  1017.  
  1018. # sudo user aliases
  1019. alias abs="sudo abs"                            # update abs database
  1020. alias chi="sudo chattr +i"                      # immunize file
  1021. alias chu="sudo chattr -i"                      # unimmunize file
  1022. alias clams="sudo clam -r -l $HOME/.clamlog /"  # scan whole system
  1023. alias freshc="dstart clamav ; freshclam ; dstop clamav"      # update clamav database
  1024. alias freshclam="sudo freshclam"        # freshclam
  1025. alias hdparm="sudo hdparm"                      # hdparm
  1026. alias hlt="sudo shutdown -h now"                # halt now
  1027. alias hltin="sudo shutdown -h"                  # halt in n minutes
  1028. alias mkinitcpio="sudo mkinitcpio"              # mkinitcpio
  1029. alias ifconfig="sudo ifconfig"                  # ifconfig
  1030. alias mnt="mount"                               # mount
  1031. alias modprobe="sudo modprobe"                  # modprobe
  1032. alias mount="sudo mount"                        # mount
  1033. alias p="sudo pacman"                           # sudo pacman-color
  1034. alias pin="sudo pacman-color -S"                # install
  1035. alias pout="sudo pacman-color -R"               # remove
  1036. alias pq="sudo pacman-color -Q | grep -i"       # query
  1037. alias pqe="sudo pacman-color -Qe"               # show explicitly installed packages
  1038. alias pqi="sudo pacman-color -Qi"               # show information about an installed package
  1039. alias pql="sudo pacman-color -Ql"               # show files installed by a package
  1040. alias pqo="sudo pacman-color -Qo"               # search for package that owns the file
  1041. alias pqs="sudo pacman-color -Qs"               # search installed packages
  1042. alias prd="sudo pacman-color -Rd"               # remove omit dependencies
  1043. alias prs="sudo pacman-color -Rs"               # remove plus unused dependencies
  1044. alias psc="sudo pacman-color -Sc"               # clean those packages from cage that are no longer installed
  1045. alias pscc="sudo pacman-color -Scc"             # clean the whole cache directory
  1046. alias psf="sudo pacman-color -Sf"               # force (re-)installation
  1047. alias psi="sudo pacman-color -Si"               # show information about a non-local package
  1048. alias pss="sudo pacman-color -Ss"               # query database
  1049. alias psw="sudo pacman-color -Sw"               # download but don't install
  1050. alias psu="sudo pacman-color -Su"               # sys update without refresh
  1051. alias psy="sudo pacman-color -Sy"               # sync refresh
  1052. alias psyu="sudo pacman-color -Syu"             # sync refresh and update
  1053. alias psyy="sudo pacman-color -Syy"             # force all db to be refreshed
  1054. alias psyyu="sudo pacman-color -Syyu"           # force refresh and update
  1055. alias pu="sudo pacman-color -U"                 # install local pkg
  1056. alias pclean="sudo pclean"                      # .bin/pclean with sudo privileges
  1057. alias pmirror="sudo reflector -l 8 -r -o /etc/pacman.d/mirrorlist ; c /etc/pacman.d/mirrorlist" update mirrorlist
  1058. alias popt="sudo pacman-optimize"               # defrag pacman database
  1059. alias porph="sudo pacman -Rsc $(pacman -Qtdq)"  # remove orphans
  1060. alias powertop="sudo powertop"                  # powertop
  1061. alias rbt="sudo shutdown -r now"                # reboot now
  1062. alias rbtin="sudo shutdown -r"                  # reboot in n minutes
  1063. alias rmmod="sudo rmmod"                        # rmmod
  1064. alias s="sudo"                                  # lazy much
  1065. alias sa="sudo a"                               # cat
  1066. alias s-cp="sudo cp"                            # cp -i
  1067. alias scpr="sudo cpr"                           # cp -r
  1068. alias showlog="sudo tail -f /var/log/everything.log"
  1069. alias sk="sudo k"                               # kill -9
  1070. alias smv="sudo mv"                             # mv -i
  1071. alias spk="sudo pk"                             # pkill
  1072. alias srm="sudo rm"                             # rm -I
  1073. alias srmr="sudo rmr"                           # rm -Ir
  1074. alias su="su -"                                 # change to root directory
  1075. alias suh="/bin/su"                             # su to root but stay in current directory
  1076. alias sudo="sudo "                              # avoid some problems with sudo
  1077. alias suspend="sudo pm-suspend"                 # suspend
  1078. alias sv="sudo v"                               # $VISUAL
  1079. alias umnt="sudo umount"                        # umount
  1080. alias updfonts="sudo fc-cache -vf"              # update font cache
  1081.  
  1082. ## unalias everything
  1083. #unalias -a                      # uncomment to unalias everything
  1084.  
  1085. ### user functions
  1086. ## archives
  1087. ac() { # compress a file or folder
  1088.     case "$1" in
  1089.            tar.bz2|.tar.bz2) tar cvjf "${2%%/}.tar.bz2" "${2%%/}/"  ;;
  1090.        tbz2|.tbz2)       tar cvjf "${2%%/}.tbz2" "${2%%/}/"     ;;
  1091.        tbz|.tbz)         tar cvjf "${2%%/}.tbz" "${2%%/}/"      ;;     
  1092.        tar.gz|.tar.gz)   tar cvzf "${2%%/}.tar.gz" "${2%%/}/"   ;;
  1093.        tgz|.tgz)         tar cvjf "${2%%/}.tgz" "${2%%/}/"      ;;
  1094.        tar|.tar)         tar cvf  "${2%%/}.tar" "${2%%/}/"      ;;
  1095.            rar|.rar)         rar a "${2}.rar" "$2"          ;;
  1096.        zip|.zip)         zip -9 "${2}.zip" "$2"         ;;
  1097.        7z|.7z)       7z a "${2}.7z" "$2"            ;;
  1098.        lzo|.lzo)         lzop -v "$2"               ;;  
  1099.        gz|.gz)       gzip -v "$2"               ;;
  1100.        bz2|.bz2)         bzip2 -v "$2"              ;;
  1101.        xz|.xz)       xz -v "$2"                 ;;
  1102.        lzma|.lzma)       lzma -v "$2"               ;;  
  1103.            *)           echo "ac(): compress a file or directory."
  1104.             echo "Usage:   ac <archive type> <filename>"
  1105.                 echo "Example: ac tar.bz2 PKGBUILD"
  1106.             echo "Please specify archive type and source."
  1107.             echo "Valid archive types are:"
  1108.             echo "tar.bz2, tar.gz, tar, bz2, gz, tbz2, tbz,"
  1109.             echo "tgz, lzo, rar, zip, 7z, xz and lzma." ;;
  1110.     esac
  1111. }
  1112. ad() { # decompress archive (to directory $2 if wished for and possible)
  1113.    if [ -f "$1" ] ; then
  1114.        case "$1" in
  1115.            *.tar.bz2|*.tgz|*.tbz2|*.tbz) mkdir -v "$2" 2>/dev/null ; tar xvjf "$1" -C "$2" ;;
  1116.        *.tar.gz)             mkdir -v "$2" 2>/dev/null ; tar xvzf "$1" -C "$2" ;;
  1117.        *.tar)            mkdir -v "$2" 2>/dev/null ; tar xvf "$1"  -C "$2" ;;
  1118.            *.rar)            mkdir -v "$2" 2>/dev/null ; rar x   "$1"     "$2" ;;
  1119.        *.zip)            mkdir -v "$2" 2>/dev/null ; unzip   "$1"  -d "$2" ;;
  1120.        *.7z)             mkdir -v "$2" 2>/dev/null ; 7z x    "$1"   -o"$2" ;;
  1121.        *.lzo)            mkdir -v "$2" 2>/dev/null ; lzop -d "$1"   -p"$2" ;;  
  1122.        *.gz)             gunzip "$1"                       ;;
  1123.        *.bz2)            bunzip2 "$1"                      ;;
  1124.            *.Z)              uncompress "$1"                       ;;
  1125.        *.xz|*.txz|*.lzma|*.tlz)  xz -d "$1"                        ;;
  1126.        *)            
  1127.        esac
  1128.    else
  1129.                       echo "Sorry, '$2' could not be decompressed."
  1130.               echo "Usage: ad <archive> <destination>"
  1131.               echo "Example: ad PKGBUILD.tar.bz2 ."
  1132.               echo "Valid archive types are:"
  1133.               echo "tar.bz2, tar.gz, tar, bz2,"
  1134.               echo "gz, tbz2, tbz, tgz, lzo,"
  1135.               echo "rar, zip, 7z, xz and lzma"
  1136.    fi
  1137. }
  1138. al() { # list content of archive but don't unpack
  1139.     if [ -f "$1" ]; then
  1140.          case "$1" in
  1141.        *.tar.bz2|*.tbz2|*.tbz) tar -jtf "$1"     ;;
  1142.        *.tar.gz)                     tar -ztf "$1"   ;;
  1143.        *.tar|*.tgz)              tar -tf "$1"    ;;
  1144.        *.gz)                 gzip -l "$1"    ;;    
  1145.        *.rar)                rar vb "$1"     ;;
  1146.        *.zip)                unzip -l "$1"   ;;
  1147.        *.7z)                 7z l "$1"   ;;
  1148.        *.lzo)                lzop -l "$1"    ;;  
  1149.        *.xz|*.txz|*.lzma|*.tlz)      xz -l "$1"  ;;
  1150.          esac
  1151.     else
  1152.          echo "Sorry, '$1' is not a valid archive."
  1153.      echo "Valid archive types are:"
  1154.      echo "tar.bz2, tar.gz, tar, gz,"
  1155.      echo "tbz2, tbz, tgz, lzo, rar"
  1156.      echo "zip, 7z, xz and lzma"
  1157.     fi
  1158. }
  1159. ## file operations
  1160. cpd() {
  1161.   [ ! -d "$2" ] && mkdir -p "$2"
  1162.   cp "$1" "$2"
  1163. }
  1164. cpg() { # copy file and go to dir
  1165.   if [ -d "$2" ];then
  1166.     cp -irv $1 $2 && cd $2
  1167.   else
  1168.     cp -irv $1 $2
  1169.   fi
  1170. }
  1171. files() { # show amount of files in a directory
  1172.   ls -Al $1 | wc -l
  1173. }
  1174. findopen() { # find and open a file
  1175.   local PS3="select file: "
  1176.   files=( $(find "$1" -iname "$2" | sort | tr ' ' '@') )
  1177.   select file in "${files[@]//@/ }"; do
  1178.       ${3:-exo-open} "$file"
  1179.       break
  1180.   done
  1181. }
  1182. grab() { # change ownership to me
  1183.   sudo chown -R ${USER}:${USER} ${1:-.}
  1184. }
  1185. lcfiles() { # lowercase all files in a directory
  1186.   print -n 'Really lowercase all files? (yn) '
  1187.   if read -q ; then
  1188.     for i in * ; do
  1189.       mv $i $i:l
  1190.     done
  1191.   fi
  1192. }
  1193. mdc() { # make directory and cd into it
  1194.   mkdir -p "$1" && cd "$1"
  1195. }
  1196. mvd() {
  1197.   [ ! -d "$2" ] && mkdir -p "$2"
  1198.   mv "$1" "$2"
  1199. }
  1200. mvg() { # move file and go to dir
  1201.   if [ -d "$2" ];then
  1202.     mv -iv $1 $2 && cd $2
  1203.   else
  1204.     mv -iv $1 $2
  1205.   fi
  1206. }
  1207. space() { # create report of biggest files in folder $@
  1208.   du -h "$@" | sort -nr > $HOME/.space.txt && vim $HOME/.space.txt
  1209. }
  1210.  
  1211. ssanitize() { # sanitize but with sudo privileges
  1212.   sudo chmod -R u=rwX,go=rX "$@"
  1213.   sudo chown -R ${USER}:users "$@"
  1214. }
  1215. svs() { # vs but with sudo privileges
  1216.   sudo cp -iv "$1" ${1}.backup && sudo $VISUAL "$1"
  1217. }
  1218. swap() { # swap two filenames
  1219.       if [ $# -ne 2 ]; then
  1220.               echo "swap: 2 arguments needed"; return 1
  1221.       fi
  1222.       if [ ! -e $1 ]; then
  1223.               echo "swap: $1 does not exist"; return 1
  1224.       fi
  1225.       if [ ! -e $2 ]; then
  1226.               echo "swap: $2 does not exist"; return 1
  1227.       fi
  1228.       local TMPFILE=tmp.$$ ; mv $1 $TMPFILE ; mv $2 $1 ; mv $TMPFILE $2
  1229. }
  1230. up() { # go up n directories
  1231.       [ "${1/[^0-9]/}" == "$1" ] && {
  1232.       local ups=""
  1233.       for i in $(seq 1 $1)
  1234.       do
  1235.               ups=$ups"../"
  1236.       done
  1237.       cd $ups
  1238.       } || echo "usage: up INTEGER"
  1239. }
  1240.  
  1241. ## pacman
  1242. psizea() { # list all packages and sort them by their (installed) size
  1243.   LANG=C pacman -Qi | sed -n '/^Name[^:]*: \(.*\)/{s//\1 /;x};/^Installed[^:]*: \(.*\)/{s//\1/;H;x;s/\n//;p}' | sort -nk2
  1244. }
  1245. roulette() { # pacman roulette
  1246.   sudo pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
  1247. }
  1248.  
  1249. ## pictures
  1250. res() { # resize a picture to 1920 x 1200 at 90% quality
  1251.   #no arguments, print usage
  1252.   if [ $# = 0 ]
  1253.   then
  1254.     echo "Usage: res filename"
  1255.     echo "Example: res P103845.JPG"
  1256.   else
  1257.     echo "Resizing ${i:2} to 1920 x 1200 at 90% quality with filename res-$1";convert -resize 1920x1200 -quality 90 $1 res-$1
  1258.   fi
  1259. }
  1260. resa() { # resize and replace all pictures in a directory
  1261.   #no arguments, print usage
  1262.   if [ $# = 0 ]
  1263.   then
  1264.     echo "Usage: resa width height quality"
  1265.     echo "Example: resa 1920 1200 90"
  1266.   else
  1267.     for i in $(find . -maxdepth 1 -type f \-iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.bmp");
  1268.   do
  1269.     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}
  1270.   done
  1271.   fi
  1272. }
  1273. ress() { # resize a single picture specifying width, height, quality and filename
  1274.   #no arguments, print usage
  1275.   if [ $# = 0 ]
  1276.   then
  1277.     echo "Usage: ress width height quality filename"
  1278.     echo "Example: ress 1920 1200 90 P103845.JPG"
  1279.   else
  1280.     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
  1281.   fi
  1282. }
  1283. shot() { # create a screenshot with thumbnail in specified folder
  1284.   local PIC="${HOME}/.local/screenshots/%d.%m.%y_%H-%M-%S.jpg"
  1285.   scrot -q 90 $PIC
  1286. }
  1287. shotw() { # create a screenshot of a window
  1288.   local PIC="${HOME}/.local/screenshots/w_%d.%m.%y_%H-%M-%S.jpg"
  1289.   scrot -s -q 90 $PIC
  1290. }
  1291.  
  1292. ## information
  1293. cal() { # print a calender in terminal
  1294.   if [[ ! -f /usr/bin/cal ]] ; then
  1295.     echo "Please install cal before trying to use it!"
  1296.     return
  1297.   fi
  1298.   if [[ "$#" = "0" ]] ; then
  1299.     /usr/bin/cal | egrep -C 40 --color "\<$(date +%e| tr -d ' ')\>"
  1300.     echo "Today is `da`"      
  1301.   else
  1302.       cal $@ | egrep -C 40 --color "\<($(date +%B)|$(date +%e | tr -d ' '))\>"
  1303.     echo "Today is `da`"
  1304.   fi
  1305. }
  1306. ip() { # print my ip
  1307.   lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | awk '{ print $4 }' | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g'
  1308. }
  1309. freem() { # show free memory
  1310.   free -m | grep 'Mem:' | awk '{print $4}'
  1311. }
  1312. netinfo() { # show network information
  1313.   echo "--------------- Network Information ---------------"
  1314.   /sbin/ifconfig | awk /'inet addr/ {print $2}'
  1315.   /sbin/ifconfig | awk /'Bcast/ {print $3}'
  1316.   /sbin/ifconfig | awk /'inet addr/ {print $4}'
  1317.   /sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
  1318.   myip=`lynx -dump -hiddenlinks=ignore -nolist http://checkip.dyndns.org:8245/ | sed '/^$/d; s/^[ ]*//g; s/[ ]*$//g' `
  1319.   echo "${myip}"
  1320.   echo "---------------------------------------------------"
  1321. }
  1322. sysinfo() { # show information about my system
  1323.   clear
  1324.   num_cpus=`cat /proc/cpuinfo | grep -c "model name"`
  1325.   machine_cpu=`cat /proc/cpuinfo | grep -m 1 "model name" | cut -d: -f2`
  1326.   machine_mhz=`cat /proc/cpuinfo | grep -m 1 "cpu MHz" | cut -d: -f2`
  1327.   machine_cpuinfo=`uname -mp`
  1328.   todays_date=`date +"%D %r"`
  1329.   machine_uptime=`uptime`
  1330.   machine_ram=`cat /proc/meminfo | grep -m 1 "MemTotal:" | cut -d: -f2 |  sed 's/^[ \t]*//'`
  1331.   machine_video=`lspci | grep -m 1 "VGA" | cut -d: -f3 |  sed 's/^[ \t]*//'`
  1332.   machine_eth_card=`lspci | grep -m 1 "Ethernet" | cut -d: -f3 |  sed 's/^[ \t]*//'`
  1333.   machine_audio_controller=`lspci | grep -m 1 "audio" | cut -d: -f3 |  sed 's/^[ \t]*//'`
  1334.   arch_daemons=`grep "DAEMONS=" /etc/rc.conf `
  1335.   last_logins=`last | head`
  1336.   eth0info=`ifconfig eth0 | grep "inet addr:" | sed 's/inet addr/Local IP/g' | sed 's/^[ \t]*//;s/[ \t]*$//'`
  1337.   echo "ARCH LINUX - Machine Information Script ver .10"
  1338.   echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  1339.   echo "DATE: $todays_date   MACHINE NAME: $HOSTNAME  "
  1340.   echo " "
  1341.   echo "Eth0: $eth0info"
  1342.   echo "ETHERNET CARD: $machine_eth_card"
  1343.   echo "CPU INFO: Qty=$num_cpus $machine_cpuinfo"
  1344.   echo "VIDEO CARD: $machine_video"
  1345.   echo "AUDIO CONTROLLER: $machine_audio_controller"
  1346.   echo "RAM INFO: $machine_ram"
  1347.   echo " "
  1348.   echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  1349.   route
  1350.   echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  1351.   echo "DISK USAGE:"
  1352.   df -h
  1353.   echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  1354.   echo "UPTIME: $machine_uptime"
  1355.   echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  1356.   echo "$arch_daemons"
  1357.   echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  1358. }
  1359. vh() { # show basic vi help
  1360.   echo "h       Move cursor left"
  1361.   echo "l       Move cursor right"  
  1362.   echo "A       Move cursor to end of line and put in insert mode"
  1363.   echo "0       Move cursor to beginning of line"
  1364.   echo "i       Put into insert mode at current position"
  1365.   echo "a       Put into insert mode after current position"
  1366.   echo "dd          Delete line"
  1367.   echo "D       Delete text after current cursor position"
  1368.   echo "p       Paste text that was deleted"
  1369.   echo "j       Move up through history commands"
  1370.   echo "k       Move down through history commands"
  1371.   echo "u       Undo"
  1372. }
  1373. weather() { # show the weather for city $1
  1374.   declare -a WEATHERARRAY
  1375.   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 "`)
  1376.   echo ${WEATHERARRAY[@]}
  1377. }
  1378. wiki() { # open an arcticle on wikipedia
  1379.   for i ($*) $BROWSER http://de.wikipedia.org/wiki/$(sed 's| |%20|g' <<<$i)
  1380. }
  1381. awiki() {
  1382.   for i ($*) $BROWSER http://wiki.archlinux.org/index.php/$(sed 's| |%20|g' <<<$i)
  1383. }
  1384.  
  1385. ## various
  1386. del() { # manage trash can
  1387.   if [ -z $1 ]; then
  1388.     la $HOME/.local/trash
  1389.     echo "Empty Trash? (y/n)"
  1390.     read var
  1391.       if [ $var = y ]; then
  1392.         sudo rm -rf $HOME/.local/trash/*
  1393.     echo "Emptied trash."
  1394.       else
  1395.         echo "Doing nothing."
  1396.       fi
  1397.   elif [ -f $1 ]; then
  1398.     echo "Delete or just move to trash? (d/t)?"
  1399.       read var
  1400.       if [ $var = t ]; then
  1401.         mv -v $1 $HOME/.local/trash/
  1402.       elif [ $var = d ]; then
  1403.         rm -rI $1
  1404.       else
  1405.         echo 'The requested file/folder, $1, does not exist'
  1406.       fi
  1407.   fi
  1408. }
  1409. maybe() { # asks if you're really sure before executing a command
  1410.     command=$1
  1411.     shift
  1412.     echo $@ | xargs -r -p ${=command}
  1413. }
  1414. note() { # create or show notes
  1415.       #if file doesn't exist, create it
  1416.       [ -f $HOME/.notes ] || touch $HOME/.notes
  1417.       #no arguments, print file
  1418.       if [ $# = 0 ]
  1419.       then
  1420.               cat $HOME/.notes
  1421.       #clear file
  1422.       elif [ $1 = -c ]
  1423.       then
  1424.               > $HOME/.notes
  1425.       #add all arguments to file
  1426.       else
  1427.               echo "$@" >> $HOME/.notes
  1428.       fi
  1429. }
  1430. reprobe() { # remove and reinsert module
  1431.   sudo modprobe -r $1
  1432.   sudo modprobe $1
  1433. }
  1434. timer() { # remind me in n (s/m/h/d) about x (needs zenity)
  1435.   (sleep "$1" && zenity --info --text "$2") &
  1436. }
  1437.  
  1438. ### discarded for now
  1439.  
  1440. ## exported as script in .bin, so not needed as function anymore:
  1441. #q() { # run quietly and detached from terminal
  1442. #$* &>/dev/null &
  1443. #disown %%
  1444. #}
  1445.  
  1446. #rmspaces() { # no worky
  1447. #  ls | while read -r FILE
  1448. #  do
  1449. #    mv -v "$FILE" `echo $FILE | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | tr '[A-Z]' '[a-z]' | sed 's/_-_/_/g'`
  1450. #  done
  1451. #}
  1452.  
  1453. #rest() { # create thumbnail of pictures and move them to the directory final
  1454. #    fmt="jpg"
  1455. #    imgsz="100%"
  1456. #    tmbsz="15%"
  1457. #    id=1
  1458. #    while [ $# -gt 0 ] ; do
  1459. #        case "$1" in
  1460. #            -f)
  1461. #                fmt=$2 ; shift 2 ;;
  1462. #            -i)
  1463. #                imgsz=$2 ; shift 2 ;;
  1464. #            -t)
  1465. #               tmbsz=$2 ; shift 2 ;;
  1466. #            -n)
  1467. #                id=$2 ; shift 2 ;;
  1468. #            -s)
  1469. #                sfx=$2 ; shift 2 ;;
  1470. #            -p)
  1471. #                pfx=$2 ; shift 2 ;;
  1472. #            *)
  1473. #                echo 'error: ' $1 $2
  1474. #                shift 1 ;;
  1475. #        esac
  1476. #    done
  1477. #    mkdir final
  1478. #    ls *.* | while read img ; do
  1479. #       echo "$img    -> $id.$fmt"            
  1480. #       convert $img -scale $imgsz final/$pfx$id$sfx.$fmt &
  1481. #       convert $img -scale $tmbsz final/$pfx$id\_t$sfx.$fmt &            
  1482. #       id=$((id+1))
  1483. #  done
  1484. #}
Add Comment
Please, Sign In to add comment