D
Deleted member 48958
Guest
- Install it # pkg ins -y shells/zsh.
- Set it as your login shell # chsh -s /usr/local/bin/zsh your_user_name.
- Relogin.
Code:
# if user is not root, start tmux with shell
#[[ $UID -ne 0 && ! $TMUX ]] && exec tmux
# autologout when no commands were entered for 60 min.
#export TMOUT=3600
export EDITOR=vim PAGER=less LESS="-giAMR" CLICOLOR=1
export LS_COLORS='di=32:ln=35:so=33:pi=31:ex=34:bd=34;40:cd=35;40:su=30;42:sg=37;42:tw=30;46:ow=31;46'
export LSCOLORS=cxfxdxbxexeafaachcagbg
PROMPT='%(1j.%j.) %B%F{green}%C %b%f%# '
HISTFILE=$HOME/.zhistory
HISTSIZE=100000
SAVEHIST=100000
LISTMAX=999
setopt notify # report the status of background jobs immediately
setopt correct # try to correct the spelling of commands
setopt auto_cd # if the command is the name of a directory, perform cd
setopt auto_list # automatically list choices on an ambiguous completion
setopt auto_continue # unsuspend suspended jobs on "disown" command
setopt chase_links # resolve symlink to its real value when cd into it
setopt append_history # append history to the history file, rather than replace it
setopt inc_append_history # history lines are added to the $HISTFILE as soon as they are entered
setopt extended_history # save command beginning timestamp and the duration
setopt hist_reduce_blanks # remove superfluous blanks from history
setopt hist_ignore_dups # do not save history line if it duplicates previous history event
setopt hist_ignore_all_dups # if new command duplicates an older one, remove the older from history
setopt hist_expire_dups_first # when delete duplicates in history, delete oldest history event
setopt hist_save_no_dups # when writing history, older commands that duplicate newer ones are omitted
setopt hist_ignore_space # do not save line to the history list when first character is a space
setopt hist_verify # perform history expansion and reload the line into the editing buffer
#setopt share_history # share history between all sessions
setopt rec_exact # recognize exact matches even if they are ambiguous
setopt auto_pushd # cd push the old directory onto the directory stack
setopt pushd_ignore_dups # don't push multiple copies of the same directory onto the directory stack
setopt pushd_silent # do not print the directory stack after pushd or popd
setopt check_jobs # report the status of jobs before exiting
setopt long_list_jobs # list jobs in long format by default
setopt glob_complete # do not insert all the words resulting from the wildcard expansion
setopt extended_glob # treat the "#", "~" and "^" characters as part of patterns
setopt csh_null_glob # report an error when all the patterns in a command have no matches
#unsetopt bad_pattern # disable "bad pattern" error
#unsetopt nomatch # do not show an error when using glob without quotes
unsetopt hup # do not kill running jobs when shell exits
unsetopt auto_remove_slash # disable automatic removing of slash
unsetopt auto_menu # do not use menu completion
unsetopt check_running_jobs # complain only about suspended jobs on exit
#unsetopt list_types # don't show file trailing identifying mark (@,*...)
unsetopt beep # disable beep
[[ $UID -eq 0 ]] && setopt dot_glob # when logged in as root, completion uses dotfiles
autoload -Uz compinit; compinit
autoload -U select-word-style; select-word-style b
zstyle ':completion:*' use-cache true
zstyle ':completion:*' cache-path ~/.zsh/
#zstyle ':completion:*' users iluxa root test
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' accept-exact-dirs true
zstyle ':completion:*' squeeze-slashes true
zstyle ':completion:*' file-sort links reverse
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' completer _expand _complete _files _expand_alias _correct _approximate
zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}'
zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories
zstyle ':completion:*:commands' rehash true
zstyle ':completion:*:functions' ignored-patterns '_*'
zstyle ':completion:*:*:*:*:processes' command 'ps -U $USER -o pid,%mem,user,start,command -w'
zstyle ':zle:*' word-chars '*?_-[]~'
zstyle ':zle:*kill-word' word-chars '*?_-.[]~'
# select emacs keymap
bindkey -e
# alt+z/shift+alt+z
bindkey '\ez' undo
bindkey '\eZ' redo
# del key
bindkey '\e[3~' delete-char
# alt+del
bindkey '\e[3;3~' kill-word
# alt+left/right
bindkey '\e[1;3D' backward-kill-word
bindkey '\e[1;3C' kill-word
# alt+up/down
bindkey '\e[1;3A' backward-kill-line
bindkey '\e[1;3B' kill-line
# ctrl+left/right
bindkey '\e[1;5D' backward-word
bindkey '\e[1;5C' forward-word
# ctrl+up/down
bindkey '\e[1;5A' beginning-of-line
bindkey '\e[1;5B' end-of-line
# end/home
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '\e[H' beginning-of-line
bindkey '\e[F' end-of-line
# up/down to autocomplete from history, moving cursor to end of line
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey '\e[A' history-beginning-search-backward-end
bindkey '\e[B' history-beginning-search-forward-end
bindkey '\eOA' history-beginning-search-backward-end
bindkey '\eOB' history-beginning-search-forward-end
# ctrl+alt+up/down to search history
bindkey '\e[1;7A' history-incremental-search-backward
bindkey '\e[1;7B' history-incremental-search-forward
# ctrl+alt+left/right to mo move cursor using different "word-chars"
bindkey '\e[1;7C' emacs-forward-word
bindkey '\e[1;7D' emacs-backward-word
# shift+tab - reverse menu
bindkey '\e[Z' reverse-menu-complete
# disable alt+x
bindkey -r '\ex'
# list dir with TAB, when there are only spaces/no text
# before cursor, or complete text, that is before cursor only
_nice_autolist() { if [[ ${LBUFFER// } ]]
then zle expand-or-complete
else BUFFER=ls\ CURSOR=3 zle list-choices
zle end-of-list; fi }
zle -N _nice_autolist
bindkey '\CI' _nice_autolist
# ctrl+b - return to previous dir
_back() { pushd +1 && zle reset-prompt && zle -M "dirs: `dirs`" }
zle -N _back
bindkey '\Cb' _back
# ctrl+f - resume job
_foreground() { CURSOR=0 LBUFFER+=' fg %' && zle accept-line }
zle -N _foreground
bindkey '\CF' _foreground
# ctrl+r - update shell history
_read_hist() { fc -R && zle -M 'history updated' }
zle -N _read_hist
bindkey '\CR' _read_hist
# ctrl+u - go to upper dir
_go_up() { cd .. && zle reset-prompt && zle -M "pwd: $PWD" }
zle -N _go_up
bindkey '\CU' _go_up
# alt+h - last 30 history lines
_last_hist() { zle -M "`fc -rld -30`"}
zle -N _last_hist
bindkey "\eh" _last_hist
# alt+j - list jobs
_list_jobs() { zle -M "`jobs -l`"}
zle -N _list_jobs
bindkey "\ej" _list_jobs
# ctrl+del - delete character from beginning of line
_del_first_char() { CURSOR=0 zle delete-char }
zle -N _del_first_char
bindkey "\e[3;5~" _del_first_char
# alt+c - copy current line to X CLIPBOARD (x11/xclip required)
_xclipcopy() { if [[ ${DISPLAY+X} && ${BUFFER// } ]]
then print -rn -- $BUFFER | xclip -i -selection c
zle -M "\"$BUFFER\" saved to X CLIPBOARD"; fi }
zle -N _xclipcopy
bindkey "\ec" _xclipcopy
# alias -es
#alias -g @@='| grep -i --color'
#alias -g '^^'="| $PAGER"
#alias -g '%#'='| wc -l'
#alias -g %+='| tee -a'
#alias -g %%='| sort'
#alias -g %%-='| head'
#alias -g %%_='| tail'
#alias -g %%cp='| xclip -i -selection c'
alias -g ...='../../'
alias -g ....='../../../'
alias -g .....='../../../../'
alias .='pwd'
alias c='cat'
alias r='readlink -f'
alias history='fc -l -E 1'
alias l='less'
alias f='find'
alias d='diff'
alias e='builtin echo'
alias t='touch'
alias ls='ls -F'
alias la='ls -a'
alias ll='ls -lht'
alias rm='rm -I'
alias grep='grep --color'
alias g='grep -i'
alias v='vim'
alias du='du -h'
alias mkdir='mkdir -p'
alias stat='stat -x'
if you'll press TAB twice, current dir content will be displayed above prompt.
To move completion suggestions above prompt when current line isn't empty,
just press HOME key and press TAB.
Last edited by a moderator: