From 866d2e28ba9233a9b0223960ed5665192f60bd5e Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Fri, 18 May 2012 13:09:58 +0400 Subject: [PATCH] Initial commit --- aliases.sh | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++ bindings.sh | 6 ++++ constants.sh | 41 ++++++++++++++++++++++ extensions.sh | 24 +++++++++++++ functions.sh | 65 ++++++++++++++++++++++++++++++++++ main.sh | 48 +++++++++++++++++++++++++ prompt.sh | 15 ++++++++ title.sh | 56 +++++++++++++++++++++++++++++ user.sh | 5 +++ 9 files changed, 357 insertions(+) create mode 100755 aliases.sh create mode 100755 bindings.sh create mode 100755 constants.sh create mode 100755 extensions.sh create mode 100755 functions.sh create mode 100755 main.sh create mode 100755 prompt.sh create mode 100755 title.sh create mode 100755 user.sh diff --git a/aliases.sh b/aliases.sh new file mode 100755 index 0000000..dbb8f49 --- /dev/null +++ b/aliases.sh @@ -0,0 +1,97 @@ +#!/bin/zsh +# vim: set filetype=zsh + +# list dir operations +alias ls='ls --classify --color --human-readable --group-directories-first' +alias la='ls -a' +alias ll='ls -l' +alias l='ll' +alias lh='ls -h' +alias lla='ls -la' +alias llh='ls -lh' +alias llah='ls -lah' +alias llha='llah' +alias fls="fls -rd" + +# file operations +alias cp='nocorrect cp --verbose --recursive --preserve=all' +alias mv='nocorrect mv --verbose' +alias rm='nocorrect rm -v' +alias ln='ln -vi' +alias chmod='chmod -v' +alias chown='chown -v' +alias chgrp='chgrp -v' +alias mkdir='mkdir -v' +alias rmdir='rmdir -v' + +# fs statistics +alias df='df -hT' +alias dfm='df -mT' +alias fs='du -shcx * .* | sort -h' +alias du='du --human-readable --total' + +# process operations +alias nohup='nohup > /dev/null $1' +alias k='killall' +which sudo &>/dev/null && alias sk='sudo killall' + +# autofixing +alias cd..='cd ..' +alias cd~='cd ~' +alias cd-='cd -' + +alias v='vim' +which sudo &>/dev/null && alias sv='sudo vim' + +alias grep='grep --color=always' + +which grc &>/dev/null && { + alias grc='grc --colour=auto' + alias ping='grc ping' + alias last='grc last' + alias netstat='grc netstat' + alias traceroute='grc traceroute' + alias make='grc make' + alias gcc='grc gcc' + alias configure='grc ./configure' + alias configure='grc configure' + alias netstat='grc netstat' + alias ping='grc ping' + alias cat="grc cat" + alias tail="grc tail" + alias head="grc head" +} + +alias killall="killall --interactive --verbose" + +alias free="free -t -m" + +which git &>/dev/null && alias git="nocorrect git" +which hg &>/dev/null && alias hg="nocorrect hg" + +which scrot &>/dev/null && alias scrot="scrot --border --count --quality 75 $HOME'/screenshots/%d-%b-%y_%H-%M-%S_\$wx\$h.png' --exec 'du -h \$f'" + +which sudo &>/dev/null && alias su='sudo su -' +which hd &>/dev/null && alias hd='hexdump -C' +which sudo &>/dev/null && alias krnlconfig="sudo make MENUCONFIG_MODE=single_menu MENUCONFIG_COLOR=mono menuconfig" +which valgrind &>/dev/null && alias valgrind='valgrind --tool=callgrind' +which cgdb &>/dev/null && alias cgdb='LANG=ru_RU.koi8-r cgdb' +which rsync &>/dev/null && alias cpb='rsync --progress -h' \ + && alias cpbs='rsync --progress -h -rax --delete-excluded' +which alsamixer &>/dev/null && alias alsamixer='alsamixer -g' && alias equilizer='alsamixer -D equal' +[ -x /usr/libexec/mc/mc-wrapper.sh ] && alias mc='. /usr/libexec/mc/mc-wrapper.sh -x' +which network.sh &>/dev/null && alias net='network.sh' +which colordiff &>/dev/null && alias diff='colordiff' +alias make="make -j$((`grep "^processor" /proc/cpuinfo | wc -l`+1)) 2>/dev/null" +which colormake &>/dev/null && alias make="colormake -j$((`grep "^processor" /proc/cpuinfo | wc -l`+1)) 2>/dev/null" +which colorgcc &>/dev/null && { + alias c++='/usr/lib/colorgcc/bin/c++' + alias cc='/usr/lib/colorgcc/bin/cc' + alias g++='/usr/lib/colorgcc/bin/g++' + alias gcc='/usr/lib/colorgcc/bin/gcc' +} +which astyle &>/dev/null && { + alias astyle-glib='astyle --style=gnu --indent=spaces=2 --max-instatement-indent=80 \ + --indent-preprocessor --indent-col1-comments --break-blocks=all \ + --pad-oper --pad-header --break-closing-brackets --add-brackets' +} diff --git a/bindings.sh b/bindings.sh new file mode 100755 index 0000000..b2cf58a --- /dev/null +++ b/bindings.sh @@ -0,0 +1,6 @@ +#!/bin/zsh +# vim: set filetype=zsh + +bindkey -v +bindkey '\e[3~' delete-char +bindkey '^R' history-incremental-search-backward diff --git a/constants.sh b/constants.sh new file mode 100755 index 0000000..9b18d96 --- /dev/null +++ b/constants.sh @@ -0,0 +1,41 @@ +#!/bin/zsh +# vim: set filetype=zsh + +ZDOTDIR=~/.zsh + +export BC_ENV_ARGS="--quiet --mathlib" + +export HISTTIMEFORMAT="%t%d.%m.%y %H:%M:%S%t" +export HISTCONTROL="ignoredupes" +export HISTIGNORE="&:ls:[bf]g:exit: cd \"\`*: PROMPT_COMMAND=\'*:cd \'/*" +export PROMPT_COMMAND='history -a' + +export LS_COLORS="di=01;34:fi=0:ln=01;36:pi=43:so=45:bd=46:cd=40:or=05;41:mi=05;41:ex=01;32" + +export PATH="$PATH:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/bin:$HOME/scripts:$HOME/bin" +[ -x /usr/bin/src-hilite-lesspipe.sh ] && export LESSOPEN="| /usr/bin/src-hilite-lesspipe.sh %s" +export LESS=' -R ' +[ -x /usr/bin/vim ] && export EDITOR=/usr/bin/vim + +# type a directory's name to cd to it +compctl -/ cd + +# tab completion for PID :D +zstyle ':completion:*:*:kill:*' menu yes select +zstyle ':completion:*:kill:*' force-list always + +HISTFILE=~/.zsh/.histfile +HISTSIZE=1000 +SAVEHIST=1000 + +export LANG="ru_RU.UTF-8" +export LC_PAPER="ru_RU.UTF-8" +export LC_MEASUREMENT="ru_RU.UTF-8" +export LC_TIME="ru_RU.UTF-8" +#export LC_ALL="en_US.UTF-8" + +case $TERM in + screen) + export PROMPT_COMMAND='echo -n -e "\033k\033\\"' + ;; +esac diff --git a/extensions.sh b/extensions.sh new file mode 100755 index 0000000..242c364 --- /dev/null +++ b/extensions.sh @@ -0,0 +1,24 @@ +#!/bin/zsh +# vim: set filetype=zsh + +# file extensions +[[ -z $DISPLAY ]] && { + alias -s {jpg,jpeg,bmp,gif,png,svg,xbm,psd}="fbi" + alias -s {avi,mpeg,mpg,3gp}="mplayer" + alias -s {html,htm}="links -g" + alias -s {pdf}=apvlv + alias -s {txt,lst}="cat" +} || { + alias -s {jpg,jpeg,bmp,gif,png,svg}="nohup &>/dev/null gqview" + alias -s {pdf,djvu}="nohup &> /dev/null evince" + which gnome-mplayer &>/dev/null && alias -s {avi,mpeg,mpg,3gp}="nohup &>/dev/null gnome-mplayer" || alias -s {avi,mpeg,mpg,3gp}="nohup &>/dev/null mplayer" + alias -s {odt,doc,sxw,rtf,odf,xls,ppt}="nohup &> /dev/null soffice" + alias -s {html,htm}="firefox" + alias -s {txt,lst}="cat" + alias -s exe="wine" +} + +alias -s {wav,mp3,ogg}="alsaplayer" + +autoload -U pick-web-browser +alias -s {html,htm,xhtml}=pick-web-browser diff --git a/functions.sh b/functions.sh new file mode 100755 index 0000000..a7adec2 --- /dev/null +++ b/functions.sh @@ -0,0 +1,65 @@ +#!/bin/zsh +# vim: set filetype=zsh + +cdl() { cd $1 && ls } + +mkcd() { mkdir $1 && cd $1 } + +rcd() { cd .. && rm -irfv $OLDPWD } + +extract () { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.tar.xz) tar xJf $1 ;; + *.bz2) bunzip2 $1 ;; + *.lbz2) lbunzip2 -kn$((`grep "^processor" /proc/cpuinfo | wc -l`+1)) $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tbz) tar -xjvf $1 ;; + *.tgz) tar xzf $1 ;; + *.txz) tar xJf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "I don't know how to extract '$1'..." ;; + esac + else + echo "'$1' is not a valid file" + fi +} + + +pk () { + if [ $1 ] ; then + case $1 in + tbz) tar cjvf $2.tar.bz2 $2 ;; + tgz) tar czvf $2.tar.gz $2 ;; + tgz) tar cJvf $2.tar.xz $2 ;; + tar) tar cpvf $2.tar $2 ;; + bz2) bzip2 $2 ;; + lbz2) lbzip2 -kn$((`grep "^processor" /proc/cpuinfo | wc -l`+1)) $2 ;; + gz) gzip -c -9 -n $2 > $2.gz ;; + xz) xz -c -9 $2 > $2.xz ;; + zip) zip -r $2.zip $2 ;; + 7z) 7z a $2.7z $2 ;; + *) echo "'$1' cannot be packed via pk()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} + +calc() { + echo $* | bc +} + +vcs_info_wrapper() { + vcs_info + if [ -n "$vcs_info_msg_0_" ]; then + echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del" + fi +} diff --git a/main.sh b/main.sh new file mode 100755 index 0000000..0f2c572 --- /dev/null +++ b/main.sh @@ -0,0 +1,48 @@ +#!/bin/zsh +# vim: set filetype=zsh + +umask 002 + +zstyle ':completion:*' completer _expand _complete _ignored +zstyle ':completion:*' group-name '' +zstyle ':completion:*' list-colors '' +zstyle ':completion:*' list-prompt '%SAt %p: Hit TAB for more, or the character to insert%s' +zstyle ':completion:*' max-errors 1 +zstyle ':completion:*' menu select=long-list select=0 +zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' +zstyle ':completion:*' use-compctl false +zstyle ':completion:*' verbose true +zstyle :compinstall filename "/home/$USER/.zsh/.zshrc" +zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' +zstyle ':completion:history-words:*:history-words' stop yes +zstyle ':completion:history-words:*:history-words' list no +zstyle ':completion:history-words:*' remove-all-dups yes +zstyle ':completion:history-words:*' menu yes + +autoload -Uz compinit +compinit +setopt appendhistory sharehistory autocd beep extendedglob nomatch notify + +zstyle ':completion:*:processes' command 'ps -xuf' +zstyle ':completion:*:processes' sort false + +zstyle ':completion:*:processes-names' command 'ps xho command' + +setopt correctall +setopt noflowcontrol + +# history +setopt hist_allow_clobber +setopt hist_ignore_dups +setopt hist_ignore_space +setopt hist_no_store +setopt hist_expire_dups_first +setopt hist_find_no_dups +setopt extended_history +setopt inc_append_history + +unsetopt equals + +stderred_lib_path=`whereis stderred.so | cut -d: -f2 | cut -d" " -f2` +[[ "" != "$stderred_lib_path" ]] && alias stderred="LD_PRELOAD=$stderred_lib_path" +unset stderred_lib_path diff --git a/prompt.sh b/prompt.sh new file mode 100755 index 0000000..093aef8 --- /dev/null +++ b/prompt.sh @@ -0,0 +1,15 @@ +#!/bin/zsh +# vim: set filetype=zsh + +setopt prompt_subst +autoload -Uz vcs_info +zstyle ':vcs_info:*' actionformats \ + '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{3}|%F{1}%a%F{5}]%f ' +zstyle ':vcs_info:*' formats \ + '%F{5}(%f%s%F{5})%F{3}-%F{5}[%F{2}%b%F{5}]%f ' +zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{1}:%F{3}%r' +zstyle ':vcs_info:*' enable git hg cvs svn +zstyle ':vcs_info:*' disable-patterns "$HOME(/smb*|/.big/smb*)" + +PROMPT=$'%B%{\e[0;36m%}┌─[%{\e[0;36m%}%n%{\e[0;36m%}@%{\e[0;32m%}%m%{\e[0;36m%} (%T)]──(%{\e[0;33m%}%~%{\e[0;36m%})\n└─[%{\e[0;39m%}%# %{\e[0;36m%}>%b ' +RPROMPT=$'$(vcs_info_wrapper)' diff --git a/title.sh b/title.sh new file mode 100755 index 0000000..af6c0e5 --- /dev/null +++ b/title.sh @@ -0,0 +1,56 @@ +#!/bin/zsh +# vim: set filetype=zsh + +# Terminal title updating for Zsh by haa +# At prompt, display current path name + +[[ ! -z $DISPLAY ]] && { + precmd () { + echo -n "\e]0;" + # Enable on remote servers to show hostname: + #print -Pn "%m: " + + print -Pn '%(!.# .)' # Print # for root shell + case "$PWD" in + ??????????????????????????????????????????????????*) + # Longer than 50, display "...endofpath" + # Change nonprintable characters into '?'s + echo -nE "...${(l:50:::::)PWD//[^[:print:]]/?}" + ;; + *) + echo -nE "${PWD//[^[:print:]]/?}" + ;; + esac + print -Pn " (%m)" + echo -n "\007" + } + # When running, display commandline + preexec () { + echo -n "\e]0;" + # Enable on remote servers to show hostname: + #print -Pn "%m: " + print -Pn '%(!.# .)' # Print # for root shell + case "$1" in + ??????????????????????????????????????????????????*) + # Longer than 50, display "commandlinestart..." + echo -nE "${(r:50:::::)1//[^[:print:]]/?}..." + ;; + *) + echo -nE "${1//[^[:print:]]/?}" + ;; + esac + print -Pn " (%m)" + echo -n "\007" + } + + # AddAlias by haa + # addalias aliasname command with parameters you just ran + addalias(){ + echo -n "Comment> " + read comment + name="$1" + shift + echo "alias $name=\"$*\" # $comment" >> $HOME/.zshenv + alias $name="$*" + } +} diff --git a/user.sh b/user.sh new file mode 100755 index 0000000..b1bafcb --- /dev/null +++ b/user.sh @@ -0,0 +1,5 @@ +#!/bin/zsh +# vim: set filetype=zsh + +export NAME="Kolan Sh." +export EMAIL=mecareful@gmail.com