init
This commit is contained in:
commit
91afdcbd6c
5
Makefile
Normal file
5
Makefile
Normal file
|
@ -0,0 +1,5 @@
|
|||
install:
|
||||
mv ../.zshrc zshrc.bak
|
||||
ln -s zshrc ../.zshrc
|
||||
touch history private
|
||||
|
23
README
Normal file
23
README
Normal file
|
@ -0,0 +1,23 @@
|
|||
# @author Sebastian Tramp <mail@sebastian.tramp.name>
|
||||
# @license http://opensource.org/licenses/gpl-license.php
|
||||
|
||||
Due to many requests I share my zsh configuration compilation.
|
||||
Copy the repository to ~/.zsh and run 'make install' once
|
||||
(or link the ~/.zsh/zshrc manually to ~/.zshrc)
|
||||
|
||||
### File description
|
||||
~/.zsh/README - This file
|
||||
~/.zsh/Makefile - make-config to run with 'make install'
|
||||
~/.zsh/aliases - alias definitions which can be edited/modified with 'aedit'
|
||||
~/.zsh/completion - tab completion configuration
|
||||
~/.zsh/functions - functions and key bindings to that functions
|
||||
~/.zsh/options - shell options as history size, general keyindings, etc
|
||||
~/.zsh/prompt - the prompt definition
|
||||
~/.zsh/zshrc - the main RC file (will be linked to ~/.zshrc)
|
||||
|
||||
### These files are not in the repository but will be created
|
||||
~/.zsh/history - the history file (shared for all zsh instances)
|
||||
~/.zsh/private - private commands/aliases etc. (included at the end)
|
||||
this should also include definitions for
|
||||
EDITOR, PAGER, cdpath, fpath etc.
|
||||
|
88
aliases
Normal file
88
aliases
Normal file
|
@ -0,0 +1,88 @@
|
|||
# @author Sebastian Tramp <mail@sebastian.tramp.name>
|
||||
# @license http://opensource.org/licenses/gpl-license.php
|
||||
#
|
||||
# alias definitions which can be edited/modified with 'aedit'
|
||||
#
|
||||
|
||||
alias aedit=" nano ~/.zsh/aliases; source ~/.zsh/aliases"
|
||||
alias fedit=" nano ~/.zsh/functions; source ~/.zsh/functions"
|
||||
alias pedit=" nano ~/.zsh/private; source ~/.zsh/private"
|
||||
|
||||
#alias man="unset PAGER; man"
|
||||
alias grep='grep --color=auto'
|
||||
alias less=/usr/share/vim/vim72/macros/less.sh
|
||||
|
||||
##### standard aliases (start with a space to be ignored in history)
|
||||
alias ls='ls --color=auto'
|
||||
alias ll=' ls -lhF'
|
||||
alias la=' ls -A'
|
||||
alias l=' ls -CF'
|
||||
alias v=" clear; ls -Flgh"
|
||||
|
||||
alias g='ps aux|grep '
|
||||
alias d=' dirs -v'
|
||||
|
||||
##### global aliases
|
||||
# zsh buch s.82 (z.B. find / ... NE)
|
||||
alias -g NE='2>|/dev/null'
|
||||
alias -g NO='&>|/dev/null'
|
||||
|
||||
# http://rayninfo.co.uk/tips/zshtips.html
|
||||
alias -g G='| grep -'
|
||||
alias -g P='| $PAGER'
|
||||
|
||||
|
||||
##### suffix aliases (mostly mapped to xdg-open which runs the gnome/kde default app)
|
||||
|
||||
alias -s tex="rubber --inplace --maxerr -1 --short --force --warn all --pdf"
|
||||
|
||||
alias -s pdf="xdg-open"
|
||||
alias -s PDF="xdg-open"
|
||||
alias -s xoj="xournal"
|
||||
|
||||
alias -s jar="java -jar"
|
||||
|
||||
alias -s iso="vlc"
|
||||
alias -s avi="xdg-open"
|
||||
alias -s mpg="xdg-open"
|
||||
alias -s m4v="xdg-open"
|
||||
alias -s ogg="xdg-open"
|
||||
alias -s ogv="xdg-open"
|
||||
|
||||
alias -s tif="xdg-open"
|
||||
alias -s tiff="xdg-open"
|
||||
alias -s png="xdg-open"
|
||||
alias -s jpg="xdg-open"
|
||||
alias -s JPG="xdg-open"
|
||||
alias -s gif="xdg-open"
|
||||
alias -s svg="xdg-open"
|
||||
alias -s psd="xdg-open"
|
||||
|
||||
alias -s com="xdg-open"
|
||||
alias -s de="xdg-open"
|
||||
alias -s org="xdg-open"
|
||||
|
||||
alias -s rdf="rapper --count"
|
||||
alias -s owl="rapper --count"
|
||||
alias -s ttl="rapper -i turtle --count"
|
||||
alias -s n3="rapper -i turtle --count"
|
||||
alias -s nt="rapper -i ntriples --count"
|
||||
|
||||
alias -s ods="xdg-open"
|
||||
alias -s xls="xdg-open"
|
||||
alias -s xlsx="xdg-open"
|
||||
alias -s csv="xdg-open"
|
||||
|
||||
alias -s odt="xdg-open"
|
||||
alias -s doc="xdg-open"
|
||||
alias -s docx="xdg-open"
|
||||
alias -s rtf="xdg-open"
|
||||
alias -s dot="xdg-open"
|
||||
|
||||
alias -s ppt="xdg-open"
|
||||
alias -s odp="xdg-open"
|
||||
|
||||
alias -s sla="xdg-open"
|
||||
|
||||
alias -s exe="xdg-open"
|
||||
|
73
completion
Normal file
73
completion
Normal file
|
@ -0,0 +1,73 @@
|
|||
# @author Sebastian Tramp <mail@sebastian.tramp.name>
|
||||
# @license http://opensource.org/licenses/gpl-license.php
|
||||
#
|
||||
# tab completion configuration
|
||||
#
|
||||
|
||||
# load completions system
|
||||
zmodload -i zsh/complist
|
||||
|
||||
# for all completions: menuselection
|
||||
zstyle ':completion:*' menu select=1
|
||||
|
||||
# for all completions: grouping the output
|
||||
zstyle ':completion:*' group-name ''
|
||||
|
||||
# for all completions: color
|
||||
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||
|
||||
# for all completions: selected item
|
||||
#zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} ma=0\;47
|
||||
|
||||
# completion of .. directories
|
||||
zstyle ':completion:*' special-dirs true
|
||||
|
||||
# fault tolerance
|
||||
zstyle ':completion:*' completer _complete _correct _approximate
|
||||
# (1 error on 3 characters)
|
||||
zstyle -e ':completion:*:approximate:*' max-errors 'reply=( $(( ($#PREFIX+$#SUFFIX)/3 )) numeric )'
|
||||
|
||||
# case insensitivity
|
||||
#zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'
|
||||
zstyle ":completion:*" matcher-list 'm:{A-Zöäüa-zÖÄÜ}={a-zÖÄÜA-Zöäü}'
|
||||
|
||||
# for all completions: grouping / headline / ...
|
||||
zstyle ':completion:*:messages' format $'\e[01;35m -- %d -- \e[00;00m'
|
||||
zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found -- \e[00;00m'
|
||||
zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d -- \e[00;00m'
|
||||
zstyle ':completion:*:corrections' format $'\e[01;33m -- %d -- \e[00;00m'
|
||||
|
||||
# statusline for many hits
|
||||
zstyle ':completion:*:default' select-prompt $'\e[01;35m -- Match %M %P -- \e[00;00m'
|
||||
|
||||
# for all completions: show comments when present
|
||||
zstyle ':completion:*' verbose yes
|
||||
|
||||
# in menu selection strg+space to go to subdirectories
|
||||
bindkey -M menuselect '^@' accept-and-infer-next-history
|
||||
|
||||
# case-insensitive -> partial-word (cs) -> substring completion:
|
||||
zstyle ':completion:*' matcher-list 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
|
||||
# caching of completion stuff
|
||||
zstyle ':completion:*' use-cache on
|
||||
zstyle ':completion:*' cache-path "${HOME}/.zsh/${HOST}-cache"
|
||||
|
||||
|
||||
# ~dirs: reorder output sorting: named dirs over userdirs
|
||||
zstyle ':completion::*:-tilde-:*:*' group-order named-directories users
|
||||
|
||||
# ssh: reorder output sorting: user over hosts
|
||||
zstyle ':completion::*:ssh:*:*' tag-order "users hosts"
|
||||
|
||||
# kill: advanced kill completion
|
||||
zstyle ':completion::*:kill:*:*' command 'ps xf -U $USER -o pid,%cpu,cmd'
|
||||
zstyle ':completion::*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;32'
|
||||
|
||||
# rm: advanced completion (e.g. bak files first)
|
||||
zstyle ':completion::*:rm:*:*' file-patterns '*.o:object-files:object\ file *(~|.(old|bak|BAK)):backup-files:backup\ files *~*(~|.(o|old|bak|BAK)):all-files:all\ files'
|
||||
|
||||
zstyle :compinstall filename '~/.zshrc'
|
||||
|
||||
autoload -Uz compinit && compinit
|
||||
|
30
functions
Normal file
30
functions
Normal file
|
@ -0,0 +1,30 @@
|
|||
# @author Sebastian Tramp <mail@sebastian.tramp.name>
|
||||
# @license http://opensource.org/licenses/gpl-license.php
|
||||
#
|
||||
# functions and key bindings to that functions
|
||||
#
|
||||
|
||||
# strg+x,s adds sudo to the line
|
||||
# Zsh Buch p.159 - http://zshbuch.org/
|
||||
run-with-sudo() { LBUFFER="sudo $LBUFFER" }
|
||||
zle -N run-with-sudo
|
||||
bindkey '^Xs' run-with-sudo
|
||||
|
||||
# Top ten memory hogs
|
||||
# http://www.commandlinefu.com/commands/view/7139/top-ten-memory-hogs
|
||||
memtop() {ps -eorss,args | sort -nr | pr -TW$COLUMNS | head}
|
||||
zle -N memtop
|
||||
|
||||
# reloads all functions
|
||||
# http://www.zsh.org/mla/users/2002/msg00232.html
|
||||
r() {
|
||||
local f
|
||||
f=(~/.zsh/functions.d/*(.))
|
||||
unfunction $f:t 2> /dev/null
|
||||
autoload -U $f:t
|
||||
}
|
||||
|
||||
# activates zmv
|
||||
autoload zmv
|
||||
|
||||
|
59
options
Normal file
59
options
Normal file
|
@ -0,0 +1,59 @@
|
|||
# @author Sebastian Tramp <mail@sebastian.tramp.name>
|
||||
# @license http://opensource.org/licenses/gpl-license.php
|
||||
#
|
||||
# shell options as history size, keyindings, etc
|
||||
#
|
||||
|
||||
export GREP_OPTIONS='-D skip --binary-files=without-match --ignore-case'
|
||||
|
||||
# keybindings Strg+v is your friend :-)
|
||||
eval "`dircolors -b`"
|
||||
|
||||
bindkey "^[[1;5D" .backward-word
|
||||
bindkey "^[[1;5C" .forward-word
|
||||
bindkey "^[[1;6D" backward-delete-word
|
||||
bindkey "^[[1;6C" delete-word
|
||||
|
||||
# arrow up/down searches in history if line is already started
|
||||
bindkey '^[[A' up-line-or-search
|
||||
bindkey '^[[B' down-line-or-search
|
||||
|
||||
# History Settings (big history for use with many open shells and no dups)
|
||||
HISTFILE=~/.zsh/history
|
||||
SAVEHIST=10000
|
||||
HISTSIZE=12000
|
||||
setopt share_history append_history extended_history hist_no_store hist_ignore_all_dups hist_ignore_space
|
||||
|
||||
# 2x control is completion from history!!!
|
||||
zle -C hist-complete complete-word _generic
|
||||
zstyle ':completion:hist-complete:*' completer _history
|
||||
bindkey '^X^X' hist-complete
|
||||
|
||||
# If a command is issued that can’t be executed as a normal command, and the command is the name of a directory, perform the cd command to that directory.
|
||||
setopt AUTO_CD
|
||||
|
||||
# Treat the ‘#’, ‘~’ and ‘^’ characters as part of patterns for filename generation, etc. (An initial unquoted ‘~’ always produces named directory expansion.)
|
||||
setopt EXTENDED_GLOB
|
||||
|
||||
# If a pattern for filename generation has no matches, print an error, instead of leaving it unchanged in the argument list. This also applies to file expansion of an initial ‘~’ or ‘=’.
|
||||
setopt NOMATCH
|
||||
|
||||
# no Beep on error in ZLE.
|
||||
setopt NO_BEEP
|
||||
|
||||
# Remove any right prompt from display when accepting a command line. This may be useful with terminals with other cut/paste methods.
|
||||
setopt TRANSIENT_RPROMPT
|
||||
|
||||
# If unset, the cursor is set to the end of the word if completion is started. Otherwise it stays there and completion is done from both ends.
|
||||
setopt COMPLETE_IN_WORD
|
||||
|
||||
# Make cd push the old directory onto the directory stack.
|
||||
setopt AUTO_PUSHD
|
||||
|
||||
# Don’t push multiple copies of the same directory onto the directory stack.
|
||||
setopt PUSHD_IGNORE_DUPS
|
||||
|
||||
# DON NOT Allow ‘>’ redirection to truncate existing files, and ‘>>’ to create files. Otherwise ‘>!’ or ‘>|’ must be used to truncate a file, and ‘>>!’ or ‘>>|’ to create a file.
|
||||
setopt no_clobber
|
||||
|
||||
|
167
prompt
Normal file
167
prompt
Normal file
|
@ -0,0 +1,167 @@
|
|||
# @author Sebastian Tramp <mail@sebastian.tramp.name>
|
||||
# @license http://opensource.org/licenses/gpl-license.php
|
||||
#
|
||||
# the prompt definition
|
||||
#
|
||||
|
||||
#on#### http://aperiodic.net/phil/prompt/
|
||||
function precmd {
|
||||
local TERMWIDTH
|
||||
(( TERMWIDTH = ${COLUMNS} - 1 ))
|
||||
|
||||
###
|
||||
# Truncate the path if it's too long.
|
||||
|
||||
PR_FILLBAR=""
|
||||
PR_PWDLEN=""
|
||||
|
||||
local promptsize=${#${(%):---(%n@%m:%l)---()--}}
|
||||
local pwdsize=${#${(%):-%~}}
|
||||
|
||||
if [[ "$promptsize + $pwdsize" -gt $TERMWIDTH ]]; then
|
||||
((PR_PWDLEN=$TERMWIDTH - $promptsize))
|
||||
else
|
||||
PR_FILLBAR="\${(l.(($TERMWIDTH - ($promptsize + $pwdsize)))..${PR_HBAR}.)}"
|
||||
fi
|
||||
|
||||
###
|
||||
# Get APM info.
|
||||
|
||||
# if which ibam > /dev/null; then
|
||||
# PR_APM_RESULT=`ibam --percentbattery`
|
||||
# elif which apm > /dev/null; then
|
||||
# PR_APM_RESULT=`apm`
|
||||
# fi
|
||||
|
||||
###
|
||||
# Get Mercurial info
|
||||
PR_MESSAGE=`hg branch 2>/dev/null`
|
||||
}
|
||||
setopt extended_glob
|
||||
preexec () {
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
local CMD=${1[(wr)^(*=*|sudo|-*)]}
|
||||
echo -n "\ek$CMD\e\\"
|
||||
fi
|
||||
}
|
||||
setprompt () {
|
||||
###
|
||||
# Need this so the prompt will work.
|
||||
|
||||
setopt prompt_subst
|
||||
|
||||
|
||||
###
|
||||
# See if we can use colors.
|
||||
|
||||
autoload colors zsh/terminfo
|
||||
if [[ "$terminfo[colors]" -ge 8 ]]; then
|
||||
colors
|
||||
fi
|
||||
for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
|
||||
eval PR_$color='%{$terminfo[bold]$fg[${(L)color}]%}'
|
||||
eval PR_LIGHT_$color='%{$fg[${(L)color}]%}'
|
||||
(( count = $count + 1 ))
|
||||
done
|
||||
PR_NO_COLOUR="%{$terminfo[sgr0]%}"
|
||||
|
||||
|
||||
###
|
||||
# See if we can use extended characters to look nicer.
|
||||
|
||||
typeset -A altchar
|
||||
set -A altchar ${(s..)terminfo[acsc]}
|
||||
PR_SET_CHARSET="%{$terminfo[enacs]%}"
|
||||
PR_SHIFT_IN="%{$terminfo[smacs]%}"
|
||||
PR_SHIFT_OUT="%{$terminfo[rmacs]%}"
|
||||
PR_HBAR=${altchar[q]:--}
|
||||
PR_ULCORNER=${altchar[l]:--}
|
||||
PR_LLCORNER=${altchar[m]:--}
|
||||
PR_LRCORNER=${altchar[j]:--}
|
||||
PR_URCORNER=${altchar[k]:--}
|
||||
|
||||
|
||||
###
|
||||
# Decide if we need to set titlebar text.
|
||||
|
||||
case $TERM in
|
||||
xterm*)
|
||||
PR_TITLEBAR=$'%{\e]0;%(!.-=*[ROOT]*=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\a%}'
|
||||
;;
|
||||
screen)
|
||||
PR_TITLEBAR=$'%{\e_screen \005 (\005t) | %(!.-=[ROOT]=- | .)%n@%m:%~ | ${COLUMNS}x${LINES} | %y\e\\%}'
|
||||
;;
|
||||
*)
|
||||
PR_TITLEBAR=''
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
###
|
||||
# Decide whether to set a screen title
|
||||
if [[ "$TERM" == "screen" ]]; then
|
||||
PR_STITLE=$'%{\ekzsh\e\\%}'
|
||||
else
|
||||
PR_STITLE=''
|
||||
fi
|
||||
|
||||
|
||||
###
|
||||
# APM detection
|
||||
|
||||
# if which ibam > /dev/null; then
|
||||
# PR_APM='$PR_RED${${PR_APM_RESULT[(f)1]}[(w)-2]}%%(${${PR_APM_RESULT[(f)3]}[(w)-1]})$PR_LIGHT_BLUE:'
|
||||
# elif which apm > /dev/null; then
|
||||
# PR_APM='$PR_RED${PR_APM_RESULT[(w)5,(w)6]/\% /%%}$PR_LIGHT_BLUE:'
|
||||
# else
|
||||
# PR_APM=''
|
||||
# fi
|
||||
|
||||
###
|
||||
# Finally, the prompt.
|
||||
|
||||
# the original one
|
||||
PROMPT='
|
||||
$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
|
||||
$PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
|
||||
$PR_GREEN%(!.%SROOT%s.%n)$PR_GREEN@%m:%l\
|
||||
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
|
||||
$PR_MAGENTA%$PR_PWDLEN<...<%~%<<\
|
||||
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_URCORNER$PR_SHIFT_OUT\
|
||||
|
||||
$PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
|
||||
%(?..$PR_LIGHT_RED%?$PR_BLUE:)\
|
||||
${(e)PR_APM}$PR_YELLOW%D{%H:%M}\
|
||||
$PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
|
||||
$PR_RED$PR_MESSAGE$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
|
||||
$PR_NO_COLOUR '
|
||||
|
||||
# the modified one
|
||||
PROMPT='
|
||||
$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
|
||||
$PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
|
||||
$PR_GREEN%$PR_PWDLEN<...<%~%<<\
|
||||
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_HBAR${(e)PR_FILLBAR}$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
|
||||
$PR_MAGENTA%(!.%SROOT%s.%n)$PR_MAGENTA@%m:%l\
|
||||
$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_URCORNER$PR_SHIFT_OUT\
|
||||
|
||||
$PR_CYAN$PR_SHIFT_IN$PR_LLCORNER$PR_BLUE$PR_HBAR$PR_SHIFT_OUT(\
|
||||
%(?..$PR_LIGHT_RED%?$PR_BLUE:)\
|
||||
${(e)PR_APM}$PR_YELLOW%D{%H:%M}\
|
||||
$PR_LIGHT_BLUE:%(!.$PR_RED.$PR_WHITE)%#$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
|
||||
$PR_RED$PR_MESSAGE$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
|
||||
$PR_NO_COLOUR '
|
||||
|
||||
|
||||
RPROMPT=' $PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_BLUE$PR_HBAR$PR_SHIFT_OUT\
|
||||
($PR_YELLOW%D{%a,%b%d}$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_CYAN$PR_LRCORNER$PR_SHIFT_OUT$PR_NO_COLOUR'
|
||||
|
||||
PS2='$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
|
||||
$PR_BLUE$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT(\
|
||||
$PR_LIGHT_GREEN%_$PR_BLUE)$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT\
|
||||
$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_SHIFT_OUT$PR_NO_COLOUR '
|
||||
}
|
||||
|
||||
setprompt
|
||||
#off#### http://aperiodic.net/phil/prompt/
|
||||
|
14
zshrc
Normal file
14
zshrc
Normal file
|
@ -0,0 +1,14 @@
|
|||
# @author Sebastian Tramp <mail@sebastian.tramp.name>
|
||||
# @license http://opensource.org/licenses/gpl-license.php
|
||||
#
|
||||
# the main RC file (will be linked to ~/.zshrc)
|
||||
#
|
||||
|
||||
source ~/.zsh/options
|
||||
source ~/.zsh/completion
|
||||
source ~/.zsh/prompt
|
||||
source ~/.zsh/aliases
|
||||
source ~/.zsh/functions
|
||||
source ~/.zsh/private
|
||||
|
||||
|
Loading…
Reference in a new issue