From 2efe0bd7125cc67d9cc4dce9d25e825d1e056ba0 Mon Sep 17 00:00:00 2001 From: Nikolas Weger Date: Thu, 12 Dec 2019 16:29:20 +0100 Subject: [PATCH] updated stuff --- zsh/dircolor.zsh | 6 ++-- zsh/libs/completion.zsh | 23 ++------------ zsh/libs/directories.zsh | 30 ------------------ zsh/libs/functions.zsh | 26 +-------------- zsh/libs/grep.zsh | 5 --- zsh/libs/history.zsh | 21 +++++-------- zsh/libs/key-bindings.zsh | 66 +++++++++++++-------------------------- zsh/libs/misc.zsh | 17 ---------- zsh/libs/termsupport.zsh | 40 +++++------------------- zsh/plgs/aliases.zsh | 35 +++------------------ zsh/plgs/appup.zsh | 6 ---- zsh/plgs/cnf.zsh | 7 ----- 12 files changed, 46 insertions(+), 236 deletions(-) diff --git a/zsh/dircolor.zsh b/zsh/dircolor.zsh index a99bff3..067c9b6 100644 --- a/zsh/dircolor.zsh +++ b/zsh/dircolor.zsh @@ -1,5 +1,3 @@ -LS_COLORS='no=00;37:fi=01;34:rs=00;37:di=00;34:ln=00;36:mh=00;37:pi=40;33:so=00;35:do=00;35:bd=40;33;01:cd=40;33;01:or=00;05;37;41:mi=00;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=04;34:st=37;44:ex=00;32:*.cmd=00;33:*.exe=00;33:*.com=00;33:*.btm=00;33:*.bat=00;33:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz=01;31:*.bz2=01;31:*.bzip2=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.apk=01;31:*.gem=01;31:*.jpg=00;35:*.JPG=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.svg=00;35:*.svgz=00;35:*.mng=00;35:*.pcx=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.cgm=00;35:*.emf=00;35:*.eps=00;35:*.CR2=00;35:*.ico=00;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.html=00;32:*.rst=00;32:*.md=00;32:*.patch=00;32:*.diff=00;32:*.tex=00;32:*.doc=00;32:*.xml=00;32:*.xls=00;32:*.xlsx=00;32:*.doc=00;32:*.docx=00;32:*.ppt=00;32:*.pptx=00;32:*.key=00;32:*.pt=01;32:*.tmpl=01;32:*.in=01;32:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.m4a=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:*.mov=01;36:*.mpg=01;36:*.mpeg=01;36:*.m2v=01;36:*.mkv=01;36:*.ogm=01;36:*.mp4=01;36:*.m4v=01;36:*.mp4v=01;36:*.vob=01;36:*.qt=01;36:*.nuv=01;36:*.wmv=01;36:*.asf=01;36:*.rm=01;36:*.rmvb=01;36:*.flc=01;36:*.avi=01;36:*.fli=01;36:*.flv=01;36:*.gl=01;36:*.m2ts=01;36:*.divx=01;36:*.webm=01;36:*.axv=01;36:*.anx=01;36:*.ogv=01;36:*.ogx=01;36:*.conf=00;36:*.cnf=00;36:*.cfg=00;36:*.ini=00;36:*.properties=00;36:*.yaml=00;36:*.vcl=00;36:*.c=00;33:*.cpp=00;33:*.py=00;33:*.coffesscript=00;33:*.js=00;33:*.rb=00;33:*.sh=00;33:*.zsh=00;33:*.env=00;33:*.bash=00;33:*.php=00;33:*.java=00;33:*.zcml=00;33:*.db=00;32:*.sql=00;32:*.json=00;32:*.plist=00;32:*.fs=00;32:*.tex=01;37:*.rdf=01;37:*.owl=01;37:*.n3=01;37:*.ttl=01;37:*.nt=01;37:*.torrent=01;37:*.xml=01;37:*Makefile=01;37:*Rakefile=01;37:*build.xml=01;37:*rc=01;37:*.nfo=01;37:*README=01;37:*README.txt=01;37:*readme.txt=01;37:*README.markdown=01;37:*README.md=01;37:*.ini=01;37:*.yml=01;37:*.cfg=01;37:*.conf=01;37:*.c=01;37:*.cpp=01;37:*.cc=01;37:*.log=01;30:*.bak=01;30:*.aux=01;30:*.lof=01;30:*.lol=01;30:*.lot=01;30:*.out=01;30:*.toc=01;30:*.bbl=01;30:*.blg=01;30:*~=01;30:*#=01;30:*.part=01;30:*.incomplete=01;30:*.swp=01;30:*.tmp=01;30:*.temp=01;30:*.o=01;30:*.obj=01;30:*.pyc=01;30:*.pyo=01;30:*.class=01;30:*.cache=01;30:*.egg-info=01;30:'; -export LS_COLORS - +export LS_COLORS='no=00;37:fi=01;34:rs=00;37:di=00;34:ln=00;36:mh=00;37:pi=40;33:so=00;35:do=00;35:bd=40;33;01:cd=40;33;01:or=00;05;37;41:mi=00;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=04;34:st=37;44:ex=00;32:*.cmd=00;33:*.exe=00;33:*.com=00;33:*.btm=00;33:*.bat=00;33:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz=01;31:*.bz2=01;31:*.bzip2=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.apk=01;31:*.gem=01;31:*.jpg=00;35:*.JPG=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=00;35:*.pbm=00;35:*.pgm=00;35:*.ppm=00;35:*.tga=00;35:*.xbm=00;35:*.xpm=00;35:*.tif=00;35:*.tiff=00;35:*.png=00;35:*.svg=00;35:*.svgz=00;35:*.mng=00;35:*.pcx=00;35:*.dl=00;35:*.xcf=00;35:*.xwd=00;35:*.yuv=00;35:*.cgm=00;35:*.emf=00;35:*.eps=00;35:*.CR2=00;35:*.ico=00;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.html=00;32:*.rst=00;32:*.md=00;32:*.patch=00;32:*.diff=00;32:*.tex=00;32:*.doc=00;32:*.xml=00;32:*.xls=00;32:*.xlsx=00;32:*.doc=00;32:*.docx=00;32:*.ppt=00;32:*.pptx=00;32:*.key=00;32:*.pt=01;32:*.tmpl=01;32:*.in=01;32:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.m4a=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:*.mov=01;36:*.mpg=01;36:*.mpeg=01;36:*.m2v=01;36:*.mkv=01;36:*.ogm=01;36:*.mp4=01;36:*.m4v=01;36:*.mp4v=01;36:*.vob=01;36:*.qt=01;36:*.nuv=01;36:*.wmv=01;36:*.asf=01;36:*.rm=01;36:*.rmvb=01;36:*.flc=01;36:*.avi=01;36:*.fli=01;36:*.flv=01;36:*.gl=01;36:*.m2ts=01;36:*.divx=01;36:*.webm=01;36:*.axv=01;36:*.anx=01;36:*.ogv=01;36:*.ogx=01;36:*.conf=00;36:*.cnf=00;36:*.cfg=00;36:*.ini=00;36:*.properties=00;36:*.yaml=00;36:*.vcl=00;36:*.c=00;33:*.cpp=00;33:*.py=00;33:*.coffesscript=00;33:*.js=00;33:*.rb=00;33:*.sh=00;33:*.zsh=00;33:*.env=00;33:*.bash=00;33:*.php=00;33:*.java=00;33:*.zcml=00;33:*.db=00;32:*.sql=00;32:*.json=00;32:*.plist=00;32:*.fs=00;32:*.tex=01;37:*.rdf=01;37:*.owl=01;37:*.n3=01;37:*.ttl=01;37:*.nt=01;37:*.torrent=01;37:*.xml=01;37:*Makefile=01;37:*Rakefile=01;37:*build.xml=01;37:*rc=01;37:*.nfo=01;37:*README=01;37:*README.txt=01;37:*readme.txt=01;37:*README.markdown=01;37:*README.md=01;37:*.ini=01;37:*.yml=01;37:*.cfg=01;37:*.conf=01;37:*.c=01;37:*.cpp=01;37:*.cc=01;37:*.log=01;30:*.bak=01;30:*.aux=01;30:*.lof=01;30:*.lol=01;30:*.lot=01;30:*.out=01;30:*.toc=01;30:*.bbl=01;30:*.blg=01;30:*~=01;30:*#=01;30:*.part=01;30:*.incomplete=01;30:*.swp=01;30:*.tmp=01;30:*.temp=01;30:*.o=01;30:*.obj=01;30:*.pyc=01;30:*.pyo=01;30:*.class=01;30:*.cache=01;30:*.egg-info=01;30:'; alias ls="ls --color=tty" -zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS} \ No newline at end of file +zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS} diff --git a/zsh/libs/completion.zsh b/zsh/libs/completion.zsh index c7db2eb..220cb03 100644 --- a/zsh/libs/completion.zsh +++ b/zsh/libs/completion.zsh @@ -1,19 +1,16 @@ -# fixme - the load process here seems a bit bizarre zmodload -i zsh/complist WORDCHARS='' -unsetopt menu_complete # do not autoselect the first completion entry +unsetopt menu_complete unsetopt flowcontrol -setopt auto_menu # show completion menu on successive tab press +setopt auto_menu setopt complete_in_word setopt always_to_end -# should this be in keybindings? bindkey -M menuselect '^o' accept-and-infer-next-history zstyle ':completion:*:*:*:*:*' menu select -# case insensitive (all), partial-word and substring completion if [[ "$CASE_SENSITIVE" = true ]]; then zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*' else @@ -25,7 +22,6 @@ else fi unset CASE_SENSITIVE HYPHEN_INSENSITIVE -# Complete . and .. special directories zstyle ':completion:*' special-dirs true zstyle ':completion:*' list-colors '' @@ -37,30 +33,17 @@ else zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w" fi -# disable named-directories autocompletion zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-directories -# Use caching so that commands like apt and dpkg complete are useable zstyle ':completion::complete:*' use-cache 1 zstyle ':completion::complete:*' cache-path $ZSH_CACHE_DIR -# Don't complete uninteresting users -zstyle ':completion:*:*:*:users' ignored-patterns \ - adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \ - clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \ - gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \ - ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \ - named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \ - operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \ - rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \ - usbmux uucp vcsa wwwrun xfs '_*' +zstyle ':completion:*:*:*:users' ignored-patterns adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp usbmux uucp vcsa wwwrun xfs '_*' -# ... unless we really want to. zstyle '*' single-ignored show if [[ $COMPLETION_WAITING_DOTS = true ]]; then expand-or-complete-with-dots() { - # toggle line-wrapping off and back on again [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti rmam print -Pn "%{%F{red}......%f%}" [[ -n "$terminfo[rmam]" && -n "$terminfo[smam]" ]] && echoti smam diff --git a/zsh/libs/directories.zsh b/zsh/libs/directories.zsh index cf87bd7..28a2c94 100644 --- a/zsh/libs/directories.zsh +++ b/zsh/libs/directories.zsh @@ -1,37 +1,7 @@ -# Changing/making/removing directory setopt auto_pushd setopt pushd_ignore_dups setopt pushdminus -alias -g ...='../..' -alias -g ....='../../..' -alias -g .....='../../../..' -alias -g ......='../../../../..' - -alias -- -='cd -' -alias 1='cd -' -alias 2='cd -2' -alias 3='cd -3' -alias 4='cd -4' -alias 5='cd -5' -alias 6='cd -6' -alias 7='cd -7' -alias 8='cd -8' -alias 9='cd -9' - -alias md='mkdir -p' -alias rd=rmdir - -function d () { - if [[ -n $1 ]]; then - dirs "$@" - else - dirs -v | head -10 - fi -} -compdef _dirs d - -# List directory contents alias lsa='ls -lah' alias l='ls -lah' alias ll='ls -lh' diff --git a/zsh/libs/functions.zsh b/zsh/libs/functions.zsh index 2fa8ad2..93ade7b 100644 --- a/zsh/libs/functions.zsh +++ b/zsh/libs/functions.zsh @@ -51,7 +51,6 @@ function omz_urlencode() { if [[ -z $opts[(r)-P] ]]; then spaces_as_plus=1; fi local str="$in_str" - # URLs must use UTF-8 encoding; convert str to UTF-8 if required local encoding=$langinfo[CODESET] local safe_encodings safe_encodings=(UTF-8 utf8 US-ASCII) @@ -63,7 +62,6 @@ function omz_urlencode() { fi fi - # Use LC_CTYPE=C to process text byte-by-byte local i byte ord LC_ALL=C export LC_ALL local reserved=';/?:@&=+$,' @@ -72,14 +70,12 @@ function omz_urlencode() { if [[ -z $opts[(r)-r] ]]; then dont_escape+=$reserved fi - # $mark must be last because of the "-" + if [[ -z $opts[(r)-m] ]]; then dont_escape+=$mark fi dont_escape+="]" - # Implemented to use a single printf call and avoid subshells in the loop, - # for performance (primarily on Windows). local url_str="" for (( i = 1; i <= ${#str}; ++i )); do byte="$str[i]" @@ -97,40 +93,20 @@ function omz_urlencode() { echo -E "$url_str" } -# URL-decode a string -# -# Decodes a RFC 2396 URL-encoded (%-escaped) string. -# This decodes the '+' and '%' escapes in the input string, and leaves -# other characters unchanged. Does not enforce that the input is a -# valid URL-encoded string. This is a convenience to allow callers to -# pass in a full URL or similar strings and decode them for human -# presentation. -# -# Outputs the encoded string on stdout. -# Returns nonzero if encoding failed. -# -# Usage: -# omz_urldecode - prints decoded string followed by a newline function omz_urldecode { emulate -L zsh local encoded_url=$1 - # Work bytewise, since URLs escape UTF-8 octets local caller_encoding=$langinfo[CODESET] local LC_ALL=C export LC_ALL - # Change + back to ' ' local tmp=${encoded_url:gs/+/ /} - # Protect other escapes to pass through the printf unchanged tmp=${tmp:gs/\\/\\\\/} - # Handle %-escapes by turning them into `\xXX` printf escapes tmp=${tmp:gs/%/\\x/} local decoded eval "decoded=\$'$tmp'" - # Now we have a UTF-8 encoded string in the variable. We need to re-encode - # it if caller is in a non-UTF-8 locale. local safe_encodings safe_encodings=(UTF-8 utf8 US-ASCII) if [[ -z ${safe_encodings[(r)$caller_encoding]} ]]; then diff --git a/zsh/libs/grep.zsh b/zsh/libs/grep.zsh index abc1650..8269071 100644 --- a/zsh/libs/grep.zsh +++ b/zsh/libs/grep.zsh @@ -1,16 +1,13 @@ -# is x grep argument available? grep-flag-available() { echo | grep $1 "" >/dev/null 2>&1 } GREP_OPTIONS="" -# color grep results if grep-flag-available --color=auto; then GREP_OPTIONS+=" --color=auto" fi -# ignore VCS folders (if the necessary grep flags are available) VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}" if grep-flag-available --exclude-dir=.cvs; then @@ -19,10 +16,8 @@ elif grep-flag-available --exclude=.cvs; then GREP_OPTIONS+=" --exclude=$VCS_FOLDERS" fi -# export grep settings alias grep="grep $GREP_OPTIONS" -# clean up unset GREP_OPTIONS unset VCS_FOLDERS unfunction grep-flag-available diff --git a/zsh/libs/history.zsh b/zsh/libs/history.zsh index 9c139c0..415e614 100644 --- a/zsh/libs/history.zsh +++ b/zsh/libs/history.zsh @@ -1,22 +1,17 @@ -## History wrapper function omz_history { local clear list zparseopts -E c=clear l=list if [[ -n "$clear" ]]; then - # if -c provided, clobber the history file echo -n >| "$HISTFILE" echo >&2 History file deleted. Reload the session to see its effects. elif [[ -n "$list" ]]; then - # if -l provided, run as if calling `fc' directly builtin fc "$@" else - # unless a number is provided, show all history events (starting from 1) [[ ${@[-1]-} = *[0-9]* ]] && builtin fc -l "$@" || builtin fc -l "$@" 1 fi } -# Timestamp format case ${HIST_STAMPS-} in "mm/dd/yyyy") alias history='omz_history -f' ;; "dd.mm.yyyy") alias history='omz_history -E' ;; @@ -25,16 +20,14 @@ case ${HIST_STAMPS-} in *) alias history="omz_history -t '$HIST_STAMPS'" ;; esac -# History in cache directory: HISTSIZE=50000 SAVEHIST=10000 HISTFILE=$HOME/.cache/zsh/history -## History command configuration -setopt extended_history # record timestamp of command in HISTFILE -setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE -setopt hist_ignore_dups # ignore duplicated commands history list -setopt hist_ignore_space # ignore commands that start with space -setopt hist_verify # show command with history expansion to user before running it -setopt inc_append_history # add commands to HISTFILE in order of execution -setopt share_history # share command history data +setopt extended_history +setopt hist_expire_dups_first +setopt hist_ignore_dups +setopt hist_ignore_space +setopt hist_verify +setopt inc_append_history +setopt share_history diff --git a/zsh/libs/key-bindings.zsh b/zsh/libs/key-bindings.zsh index 0e056dc..712c5d8 100644 --- a/zsh/libs/key-bindings.zsh +++ b/zsh/libs/key-bindings.zsh @@ -1,9 +1,3 @@ -# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html -# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Zle-Builtins -# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html#Standard-Widgets - -# Make sure that the terminal is in application mode when zle is active, since -# only then values from $terminfo are valid if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then function zle-line-init() { echoti smkx @@ -15,25 +9,26 @@ if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} )); then zle -N zle-line-finish fi -bindkey -e # Use emacs key bindings +bindkey -e + +bindkey '\ew' kill-region +bindkey -s '\el' 'ls\n' +bindkey '^r' history-incremental-search-backward -bindkey '\ew' kill-region # [Esc-w] - Kill from the cursor to the mark -bindkey -s '\el' 'ls\n' # [Esc-l] - run command: ls -bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backward incrementally for a specified string. The string may begin with ^ to anchor the search to the beginning of the line. if [[ "${terminfo[kpp]}" != "" ]]; then - bindkey "${terminfo[kpp]}" up-line-or-history # [PageUp] - Up a line of history -fi -if [[ "${terminfo[knp]}" != "" ]]; then - bindkey "${terminfo[knp]}" down-line-or-history # [PageDown] - Down a line of history + bindkey "${terminfo[kpp]}" up-line-or-history +fi + +if [[ "${terminfo[knp]}" != "" ]]; then + bindkey "${terminfo[knp]}" down-line-or-history fi -# start typing + [Up-Arrow] - fuzzy find history forward if [[ "${terminfo[kcuu1]}" != "" ]]; then autoload -U up-line-or-beginning-search zle -N up-line-or-beginning-search bindkey "${terminfo[kcuu1]}" up-line-or-beginning-search fi -# start typing + [Down-Arrow] - fuzzy find history backward + if [[ "${terminfo[kcud1]}" != "" ]]; then autoload -U down-line-or-beginning-search zle -N down-line-or-beginning-search @@ -41,53 +36,34 @@ if [[ "${terminfo[kcud1]}" != "" ]]; then fi if [[ "${terminfo[khome]}" != "" ]]; then - bindkey "${terminfo[khome]}" beginning-of-line # [Home] - Go to beginning of line + bindkey "${terminfo[khome]}" beginning-of-line fi + if [[ "${terminfo[kend]}" != "" ]]; then - bindkey "${terminfo[kend]}" end-of-line # [End] - Go to end of line + bindkey "${terminfo[kend]}" end-of-line fi -bindkey ' ' magic-space # [Space] - do history expansion +bindkey ' ' magic-space -bindkey '^[[1;5C' forward-word # [Ctrl-RightArrow] - move forward one word -bindkey '^[[1;5D' backward-word # [Ctrl-LeftArrow] - move backward one word +bindkey '^[[1;5C' forward-word +bindkey '^[[1;5D' backward-word if [[ "${terminfo[kcbt]}" != "" ]]; then - bindkey "${terminfo[kcbt]}" reverse-menu-complete # [Shift-Tab] - move through the completion menu backwards + bindkey "${terminfo[kcbt]}" reverse-menu-complete fi -bindkey '^?' backward-delete-char # [Backspace] - delete backward +bindkey '^?' backward-delete-char + if [[ "${terminfo[kdch1]}" != "" ]]; then - bindkey "${terminfo[kdch1]}" delete-char # [Delete] - delete forward + bindkey "${terminfo[kdch1]}" delete-char else bindkey "^[[3~" delete-char bindkey "^[3;5~" delete-char bindkey "\e[3~" delete-char fi -# Edit the current command line in $EDITOR autoload -U edit-command-line zle -N edit-command-line bindkey '\C-x\C-e' edit-command-line -# file rename magick bindkey "^[m" copy-prev-shell-word - -# consider emacs keybindings: - -#bindkey -e ## emacs key bindings -# -#bindkey '^[[A' up-line-or-search -#bindkey '^[[B' down-line-or-search -#bindkey '^[^[[C' emacs-forward-word -#bindkey '^[^[[D' emacs-backward-word -# -#bindkey -s '^X^Z' '%-^M' -#bindkey '^[e' expand-cmd-path -#bindkey '^[^I' reverse-menu-complete -#bindkey '^X^N' accept-and-infer-next-history -#bindkey '^W' kill-region -#bindkey '^I' complete-word -## Fix weird sequence that rxvt produces -#bindkey -s '^[[Z' '\t' -# diff --git a/zsh/libs/misc.zsh b/zsh/libs/misc.zsh index 61571af..884b610 100644 --- a/zsh/libs/misc.zsh +++ b/zsh/libs/misc.zsh @@ -1,6 +1,5 @@ autoload -Uz is-at-least -# *-magic is known buggy in some versions; disable if so if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then for d in $fpath; do if [[ -e "$d/url-quote-magic" ]]; then @@ -15,21 +14,5 @@ if [[ $DISABLE_MAGIC_FUNCTIONS != true ]]; then done fi -## jobs setopt long_list_jobs - -env_default 'PAGER' 'less' -env_default 'LESS' '-R' - -## super user alias -alias _='sudo ' - -## more intelligent acking for ubuntu users -if which ack-grep &> /dev/null; then - alias afind='ack-grep -il' -else - alias afind='ack -il' -fi - -# recognize comments setopt interactivecomments diff --git a/zsh/libs/termsupport.zsh b/zsh/libs/termsupport.zsh index aa14f3f..bf7fb76 100644 --- a/zsh/libs/termsupport.zsh +++ b/zsh/libs/termsupport.zsh @@ -1,36 +1,24 @@ -# Set terminal window and tab/icon title -# -# usage: title short_tab_title [long_window_title] -# -# See: http://www.faqs.org/docs/Linux-mini/Xterm-Title.html#ss3.1 -# Fully supports screen, iterm, and probably most modern xterm and rxvt -# (In screen, only short_tab_title is used) -# Limited support for Apple Terminal (Terminal can't set window and tab separately) function title { emulate -L zsh setopt prompt_subst [[ "$EMACS" == *term* ]] && return - # if $2 is unset use $1 as default - # if it is set and empty, leave it as is : ${2=$1} case "$TERM" in cygwin|xterm*|putty*|rxvt*|ansi) - print -Pn "\e]2;$2:q\a" # set window name - print -Pn "\e]1;$1:q\a" # set tab name + print -Pn "\e]2;$2:q\a" + print -Pn "\e]1;$1:q\a" ;; screen*|tmux*) - print -Pn "\ek$1:q\e\\" # set screen hardstatus + print -Pn "\ek$1:q\e\\" ;; *) if [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then - print -Pn "\e]2;$2:q\a" # set window name - print -Pn "\e]1;$1:q\a" # set tab name + print -Pn "\e]2;$2:q\a" + print -Pn "\e]1;$1:q\a" else - # Try to use terminfo to set the title - # If the feature is available set title if [[ -n "$terminfo[fsl]" ]] && [[ -n "$terminfo[tsl]" ]]; then echoti tsl print -Pn "$1" @@ -41,14 +29,13 @@ function title { esac } -ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD +ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~" -# Avoid duplication of directory in terminals with independent dir display + if [[ "$TERM_PROGRAM" == Apple_Terminal ]]; then ZSH_THEME_TERM_TITLE_IDLE="%n@%m" fi -# Runs before showing the prompt function omz_termsupport_precmd { emulate -L zsh @@ -59,7 +46,6 @@ function omz_termsupport_precmd { title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE } -# Runs before executing the command function omz_termsupport_preexec { emulate -L zsh setopt extended_glob @@ -68,7 +54,6 @@ function omz_termsupport_preexec { return fi - # cmd name only, or if this is sudo or ssh, the next cmd local CMD=${1[(wr)^(*=*|sudo|ssh|mosh|rake|-*)]:gs/%/%%} local LINE="${2:gs/%/%%}" @@ -79,27 +64,16 @@ precmd_functions+=(omz_termsupport_precmd) preexec_functions+=(omz_termsupport_preexec) -# Keep Apple Terminal.app's current working directory updated -# Based on this answer: https://superuser.com/a/315029 -# With extra fixes to handle multibyte chars and non-UTF-8 locales - if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then - # Emits the control sequence to notify Terminal.app of the cwd - # Identifies the directory using a file: URI scheme, including - # the host name to disambiguate local vs. remote paths. function update_terminalapp_cwd() { emulate -L zsh - # Percent-encode the pathname. local URL_PATH="$(omz_urlencode -P $PWD)" [[ $? != 0 ]] && return 1 - # Undocumented Terminal.app-specific control sequence printf '\e]7;%s\a' "file://$HOST$URL_PATH" } - # Use a precmd hook instead of a chpwd hook to avoid contaminating output precmd_functions+=(update_terminalapp_cwd) - # Run once to get initial cwd set update_terminalapp_cwd fi diff --git a/zsh/plgs/aliases.zsh b/zsh/plgs/aliases.zsh index 785a09c..37bcc89 100644 --- a/zsh/plgs/aliases.zsh +++ b/zsh/plgs/aliases.zsh @@ -1,37 +1,18 @@ -# Advanced Aliases. -# Use with caution -# - -# ls, the common ones I use a lot shortened for rapid fire usage -alias l='ls -lFh' #size,show type,human readable -alias la='ls -lAFh' #long list,show almost all,show type,human readable -alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable -alias lt='ls -ltFh' #long list,sorted by date,show type,human readable -alias ll='ls -l' #long list +alias l='ls -lFh' +alias la='ls -lAFh' +alias lr='ls -tRFh' +alias lt='ls -ltFh' +alias ll='ls -l' alias ldot='ls -ld .*' alias lS='ls -1FSsh' alias lart='ls -1Fcart' alias lrt='ls -1Fcrt' -alias zshrc='${=EDITOR} ~/.zshrc' # Quick access to the ~/.zshrc file - alias grep='grep --color' alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' alias t='tail -f' -# Command line head / tail shortcuts -alias -g H='| head' -alias -g T='| tail' -alias -g G='| grep' -alias -g L="| less" -alias -g M="| most" -alias -g LL="2>&1 | less" -alias -g CA="2>&1 | cat -A" -alias -g NE="2> /dev/null" -alias -g NUL="> /dev/null 2>&1" -alias -g P="2>&1| pygmentize -l pytb" - alias dud='du -d 1 -h' alias duf='du -sh *' alias fd='find . -type d -name' @@ -48,10 +29,7 @@ alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' -# zsh is able to auto-do some kungfoo -# depends on the SUFFIX :) if is-at-least 4.2.0; then - # open browser on urls if [[ -n "$BROWSER" ]]; then _browser_fts=(htm html de org net com at cx nl se dk) for ft in $_browser_fts; do alias -s $ft=$BROWSER; done @@ -68,14 +46,12 @@ if is-at-least 4.2.0; then _media_fts=(ape avi flv m4a mkv mov mp3 mpeg mpg ogg ogm rm wav webm) for ft in $_media_fts; do alias -s $ft=mplayer; done - #read documents alias -s pdf=acroread alias -s ps=gv alias -s dvi=xdvi alias -s chm=xchm alias -s djvu=djview - #list whats inside packed file alias -s zip="unzip -l" alias -s rar="unrar l" alias -s tar="tar tf" @@ -83,5 +59,4 @@ if is-at-least 4.2.0; then alias -s ace="unace l" fi -# Make zsh know about hosts already accessed by SSH zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' diff --git a/zsh/plgs/appup.zsh b/zsh/plgs/appup.zsh index 6670696..0ed4054 100644 --- a/zsh/plgs/appup.zsh +++ b/zsh/plgs/appup.zsh @@ -1,7 +1,5 @@ -# Docker _appup_docker () { if hash docker-compose >/dev/null 2>&1; then - # Check if docker-machine has been started if hash docker-machine >/dev/null 2>&1; then if docker-machine status | grep -qi "Stopped"; then read -q "REPLY?Docker Machine is not running, would you like to start it? [y/n] " @@ -16,7 +14,6 @@ _appup_docker () { fi fi - # Check YAML extension compose_file='' compose_project_file='' @@ -26,7 +23,6 @@ _appup_docker () { compose_file='docker-compose.yaml' fi - # will look for docker-compose..yml if [ -n "$2" ]; then if [ -e "docker-compose.$2.yml" ]; then compose_project_file="docker-compose.$2.yml" @@ -35,7 +31,6 @@ _appup_docker () { fi if [ -n "$compose_project_file" ]; then - # Override project name from custom env if [ -e ".env.$2" ]; then project=$(source ".env.$2"; echo $COMPOSE_PROJECT_NAME) @@ -56,7 +51,6 @@ _appup_docker () { fi } -# Vagrant _appup_vagrant () { if hash vagrant >/dev/null 2>&1; then vagrant $1 "${@:2}" diff --git a/zsh/plgs/cnf.zsh b/zsh/plgs/cnf.zsh index 31493a0..58616b8 100644 --- a/zsh/plgs/cnf.zsh +++ b/zsh/plgs/cnf.zsh @@ -1,14 +1,7 @@ -# Uses the command-not-found package zsh support -# as seen in https://www.porcheron.info/command-not-found-for-zsh/ -# this is installed in Ubuntu - [[ -e /etc/zsh_command_not_found ]] && source /etc/zsh_command_not_found -# Arch Linux command-not-found support, you must have package pkgfile installed -# https://wiki.archlinux.org/index.php/Pkgfile#.22Command_not_found.22_hook [[ -e /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh -# Fedora command-not-found support if [ -f /usr/libexec/pk-command-not-found ]; then command_not_found_handler () { runcnf=1