From 3e15c7e178bf62658a23570a628ff6e989d32ea9 Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Wed, 14 Nov 2012 12:13:11 +0100 Subject: [PATCH] mv bash_aliases, more zsh settings --- Makefile | 2 +- bash_aliases => aliasesrc | 0 bashrc | 2 +- zsh/bindkeyrc | 37 +++++++++++++++++++++ zsh/functions/ex | 24 ++++++++++++++ zshrc | 70 ++++++++++++++++++++++++++------------- 6 files changed, 110 insertions(+), 25 deletions(-) rename bash_aliases => aliasesrc (100%) create mode 100644 zsh/bindkeyrc create mode 100644 zsh/functions/ex diff --git a/Makefile b/Makefile index 4fd7e47..1f63f7c 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ APATH := $(realpath .) RPATH := $(subst $(wildcard ~/),,$(APATH)) FILES := bin -DOTFILES := bash* flexget vim* zsh* +DOTFILES := aliasesrc bash* flexget vim* zsh* .PHONY: install $(FILES) $(DOTFILES) install: $(FILES) $(DOTFILES) diff --git a/bash_aliases b/aliasesrc similarity index 100% rename from bash_aliases rename to aliasesrc diff --git a/bashrc b/bashrc index f1800e0..8efaeea 100644 --- a/bashrc +++ b/bashrc @@ -51,7 +51,7 @@ PS1='[\u@\h \W]\$ ' [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" # Alias definitions. -[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases +[[ -f ~/.aliasesrc ]] && . ~/.aliasesrc # set PATH so it includes user's private bin if it exists [[ -d "$HOME/bin" ]] && PATH="$HOME/bin:$PATH" diff --git a/zsh/bindkeyrc b/zsh/bindkeyrc new file mode 100644 index 0000000..c2dc06f --- /dev/null +++ b/zsh/bindkeyrc @@ -0,0 +1,37 @@ +# create a zkbd compatible hash; +# to add other keys to this hash, see: man 5 terminfo +# http://zshwiki.org/home/zle/bindkeys + +typeset -A key + +key[Home]=${terminfo[khome]} +key[End]=${terminfo[kend]} +key[Insert]=${terminfo[kich1]} +key[Delete]=${terminfo[kdch1]} +key[Up]=${terminfo[kcuu1]} +key[Down]=${terminfo[kcud1]} +key[Left]=${terminfo[kcub1]} +key[Right]=${terminfo[kcuf1]} +key[PageUp]=${terminfo[kpp]} +key[PageDown]=${terminfo[knp]} + +# setup key accordingly +[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line +[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line +[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode +[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char +[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-history +[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-history +[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char +[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char + +# Finally, make sure the terminal is in application mode, when zle is +# active. Only then are the values from $terminfo valid. +function zle-line-init () { + echoti smkx +} +function zle-line-finish () { + echoti rmkx +} +zle -N zle-line-init +zle -N zle-line-finish diff --git a/zsh/functions/ex b/zsh/functions/ex new file mode 100644 index 0000000..f6fb12d --- /dev/null +++ b/zsh/functions/ex @@ -0,0 +1,24 @@ +# ex - archive extractor +# usage: ex +ex () +{ + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.tar.xz) tar -x --xz -f $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via ex()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} diff --git a/zshrc b/zshrc index 54dba89..a181dbd 100644 --- a/zshrc +++ b/zshrc @@ -1,44 +1,68 @@ -# Lines configured by zsh-newuser-install +# configure history HISTFILE=~/.histfile -HISTSIZE=10000 -SAVEHIST=20000 -setopt histignoredups -setopt histignorespace -setopt appendhistory +HISTSIZE=1000 +SAVEHIST=2000 +setopt hist_ignore_dups +setopt hist_ignore_space +setopt append_history +setopt inc_append_history +setopt extended_history -setopt autocd +# misc setopt beep setopt extendedglob setopt nomatch setopt noclobber # don't allow overwriting files with '>', use '>!' instead +setopt notify setopt rcquotes # echo 'don''t'; prints don't -unsetopt notify +# key bindings +bindkey -e # emacs key bindings, vi is weird +[[ -r ~/.zsh/bindkeyrc ]] && source ~/.zsh/bindkeyrc -bindkey -e -# End of lines configured by zsh-newuser-install -# The following lines were added by compinstall +# Completion zstyle :compinstall filename '/home/ramsi/.zshrc' +zstyle ':completion:*' list-colors '' +setopt complete_in_word # allow completion in the middle of a word autoload -Uz compinit compinit -# End of lines added by compinstall + +# populate path +typeset -U path # make path a unique array +[[ -d ~/bin ]] && path=(~/bin $path) + +# load my functions +typeset -U fpath # make fpath a unique array +[[ -d ~/.zsh/functions ]] && fpath=(~/.zsh/functions $fpath) +autoload -U ${fpath[1]}/*(:t) # loads all functions in the first element of fpath # source aliases -[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases +[[ -f ~/.aliasesrc ]] && source ~/.aliasesrc # set up prompt -autoload -U promptinit -promptinit -prompt walters +autoload -U colors && colors +PROMPT="%(?..%{$fg_bold[white]%}[%?])%{$reset_color%}[%D{%k:%M} %n@%{$fg[green]%}%m%{$reset_color%}]%# " +RPROMPT="%{$fg[green]%}%~%{$reset_color%}" # make cd act like pushd -DIRSTACKSIZE=10 -setopt autopushd # cd acts like pushd -setopt pushdminus # inverts the meaning of cp -1 and cp +1 -setopt pushdsilent # don't print dir stack everytime -setopt pushdtohome # pushd with no argumens pushes to ~ -alias dh='dirs -v' +DIRSTACKSIZE=10 # number of dirs to remember +setopt auto_pushd # cd acts like pushd +setopt pushd_minus # inverts the meaning of cp -1 and cp +1 +setopt pushd_silent # don't print dir stack everytime +setopt pushd_to_home # pushd with no argumens pushes to ~ +setopt pushd_ignore_dups # ignore dups in pushd/cd +alias dh='dirs -v' # show numbers with dirs + +setopt auto_cd # if no command matches the input, try to cd into it; .. = cd .. # set search path for cd -cdpath=( ~ /mnt ) +cdpath=(~ /mnt) + +# set up a few named directories +hash -d Skaro=/mnt/Skaro +hash -d ccr=~/ccr +hash -d src=~/src +hash -d chroot_testing=/buildsystem/testing/buildroot +hash -d chroot_master=/buildsystem/master/buildroot +hash -d chroot_lib32=/buildsystem/lib32/buildroot -- 2.48.1