Pimped zsh config

This commit is contained in:
Christian Baer 2020-05-23 10:10:24 +02:00
parent 401e2eac4c
commit e80d3cd1f4
6 changed files with 52 additions and 14 deletions

24
.zlogin
View File

@ -1,11 +1,23 @@
if [[ $UID == 0 || $EUID == 0 ]]; then # Set $PATH
PATH="/root/bin:$PATH" # Put only directories in $PATH that exist and remove duplicates
fi typeset -U path # No duplicates
path=()
PATH="$HOME/bin:$PATH" _prepath() {
for dir in "$@"; do
dir=${dir:A}
[[ ! -d "$dir" ]] && return
path=("$dir" $path[@])
done
}
PATH="$PATH:/usr/local/sbin:/usr/sbin:/sbin" _prepath /usr/local/bin /bin /usr/local/sbin # General
PATH="/usr/local/bin:$PATH" _prepath /usr/bin /usr/sbin /sbin /Library/Apple/usr/bin # macOS
_prepath /usr/sbin /sbin # FreeBSD
_prepath "$HOME/bin"
unfunction _prepath
uname -npsr uname -npsr
uptime uptime

View File

@ -1,3 +1,16 @@
_exists() { (( $+commands[$1] )) }
_exists vim && export EDITOR=vim
_exists less && export PAGER=less
if _exists vim; then
alias vim="vim -p"
alias vi="vim"
fi
unfunction _exists
alias ls='ls --color=always -h' alias ls='ls --color=always -h'
alias ll='ls -la' alias ll='ls -la'
alias ...='cd ../..' alias ...='cd ../..'

View File

@ -10,4 +10,11 @@ setopt hist_ignore_dups # ignore duplication command history list
setopt hist_ignore_space setopt hist_ignore_space
setopt hist_verify setopt hist_verify
setopt inc_append_history setopt inc_append_history
setopt share_history # share command history data setopt share_history # share command history data
# Make up and down arrow take whats typed on the commandline in to account.
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search

View File

@ -9,8 +9,10 @@ bindkey "^[[5~" up-line-or-history
bindkey "^[[6~" down-line-or-history bindkey "^[[6~" down-line-or-history
# make search up and down work, so partially type and hit up/down to find relevant stuff # make search up and down work, so partially type and hit up/down to find relevant stuff
bindkey '^[[A' up-line-or-search bindkey '^[[A' up-line-or-beginning-search # Arrow up
bindkey '^[[B' down-line-or-search bindkey '^[OA' up-line-or-beginning-search
bindkey '^[[B' down-line-or-beginning-search # Arrow down
bindkey '^[OB' down-line-or-beginning-search
bindkey "^[[H" beginning-of-line bindkey "^[[H" beginning-of-line
bindkey "^[[1~" beginning-of-line bindkey "^[[1~" beginning-of-line

View File

@ -9,10 +9,5 @@ bindkey "^[m" copy-prev-shell-word
setopt long_list_jobs setopt long_list_jobs
## pager ## pager
export PAGER=less
export LC_CTYPE=$LANG export LC_CTYPE=$LANG
export LC_ALL=de_DE.UTF-8 export LC_ALL=de_DE.UTF-8
## editor
export EDITOR=vim

View File

@ -14,3 +14,12 @@ case `uname` in
hash -d www=/usr/local/www/ngineerx hash -d www=/usr/local/www/ngineerx
;; ;;
esac esac
insert_doas() { zle beginning-of-line; zle -U "doas " }
replace_rm() { zle beginning-of-line; zle delete-word; zle -U "rm " }
zle -N insert-doas insert_doas
zle -N replace-rm replace_rm
bindkey '^s' insert-doas
bindkey '^r' replace-rm