about summary refs log tree commit diff
path: root/zsh
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>1970-01-01 03:00:00 +0300
committerAzat Bahawi <azat@bahawi.net>2022-09-20 11:51:54 +0300
commit38bab29776950ac2364ed64195b89887717c33de (patch)
treeedaaf366a55dbe96d268019124536bc504c64e87 /zsh
chore: init HEAD master
Diffstat (limited to '')
-rw-r--r--zsh/.zlogin28
-rw-r--r--zsh/.zlogout12
-rw-r--r--zsh/.zprofile6
-rw-r--r--zsh/.zsh.d/00_terminfo.zsh16
-rw-r--r--zsh/.zsh.d/10_options.zsh17
-rw-r--r--zsh/.zsh.d/20_history.zsh20
-rw-r--r--zsh/.zsh.d/30_completion.zsh77
-rw-r--r--zsh/.zsh.d/40_keybindings.zsh3
-rw-r--r--zsh/.zsh.d/50_colors.zsh3
-rw-r--r--zsh/.zsh.d/60_prompt.zsh6
-rw-r--r--zsh/.zsh.d/80_plugins.zsh32
-rw-r--r--zsh/.zsh.d/90_external.zsh6
-rw-r--r--zsh/.zshenv18
-rw-r--r--zsh/.zshrc12
-rwxr-xr-xzsh/@install10
15 files changed, 266 insertions, 0 deletions
diff --git a/zsh/.zlogin b/zsh/.zlogin
new file mode 100644
index 0000000..350d066
--- /dev/null
+++ b/zsh/.zlogin
@@ -0,0 +1,28 @@
+#!/usr/bin/env zsh
+
+(
+    autoload -U zrecompile
+
+    lazy_zrecompile()
+    {
+        if [[ -s "${1}" && ( ! -s "${1}.zwc" || "${1}" -nt "${1}.zwc" ) ]]
+        then
+            zrecompile -pq "${1}"
+        fi
+    }
+
+    FLIST=(
+        ${ZCOMPDUMP}
+        ${ZLOGIN}
+        ${ZLOGOUT}
+        ${ZPROFILE}
+        ${ZSHENV}
+        ${ZSHRC}
+        ${HOME}/.zsh.d/*.zsh
+    )
+
+    for i in ${FLIST}
+    do
+        lazy_zrecompile "${i}"
+    done
+) &!
diff --git a/zsh/.zlogout b/zsh/.zlogout
new file mode 100644
index 0000000..d23ba0a
--- /dev/null
+++ b/zsh/.zlogout
@@ -0,0 +1,12 @@
+#!/usr/bin/env zsh
+
+if [ -f "${HOME}/.bin/logout-hook" ]
+then
+    source "${HOME}/.bin/logout-hook"
+
+    rm_existing "${ZLOGIN}.zwc.old"
+    rm_existing "${ZLOGOUT}.zwc.old"
+    rm_existing "${ZPROFILE}.zwc.old"
+    rm_existing "${ZSHENV}.zwc.old"
+    rm_existing "${ZSHRC}.zwc.old"
+fi
diff --git a/zsh/.zprofile b/zsh/.zprofile
new file mode 100644
index 0000000..b8f4712
--- /dev/null
+++ b/zsh/.zprofile
@@ -0,0 +1,6 @@
+#!/usr/bin/env zsh
+
+if [ -f "${HOME}"/.profile ]
+then
+    emulate sh -c ". ${HOME}/.profile"
+fi
diff --git a/zsh/.zsh.d/00_terminfo.zsh b/zsh/.zsh.d/00_terminfo.zsh
new file mode 100644
index 0000000..5f15f4a
--- /dev/null
+++ b/zsh/.zsh.d/00_terminfo.zsh
@@ -0,0 +1,16 @@
+#!/usr/bin/env zsh
+
+if (( ${+terminfo[smkx]} )) && (( ${+terminfo[rmkx]} ))
+then
+    function zle-line-init ()
+    {
+        echoti smkx
+    }
+    zle -N zle-line-init
+
+    function zle-line-finish ()
+    {
+        echoti rmkx
+    }
+    zle -N zle-line-finish
+fi
diff --git a/zsh/.zsh.d/10_options.zsh b/zsh/.zsh.d/10_options.zsh
new file mode 100644
index 0000000..785ccb8
--- /dev/null
+++ b/zsh/.zsh.d/10_options.zsh
@@ -0,0 +1,17 @@
+#!/usr/bin/env zsh
+
+setopt CLOBBER
+setopt GLOB_DOTS
+setopt INTERACTIVE_COMMENTS
+setopt LONG_LIST_JOBS
+setopt MAGIC_EQUAL_SUBST
+setopt NOTIFY
+setopt PROMPT_SUBST
+setopt PUSHD_IGNORE_DUPS
+setopt PUSHD_SILENT
+setopt PUSHD_TO_HOME
+setopt RC_QUOTES
+unsetopt BEEP
+unsetopt BG_NICE
+unsetopt CHECK_JOBS
+unsetopt CORRECT_ALL
diff --git a/zsh/.zsh.d/20_history.zsh b/zsh/.zsh.d/20_history.zsh
new file mode 100644
index 0000000..d1931f3
--- /dev/null
+++ b/zsh/.zsh.d/20_history.zsh
@@ -0,0 +1,20 @@
+#!/usr/bin/env zsh
+
+[ "${HISTFILE: -4}" != "_zsh" ] && export HISTFILE="${HISTFILE}_zsh"
+export SAVEHIST="${HISTSIZE}"
+
+setopt APPEND_HISTORY
+setopt BANG_HIST
+setopt EXTENDED_HISTORY
+setopt HIST_EXPIRE_DUPS_FIRST
+setopt HIST_IGNORE_ALL_DUPS
+setopt HIST_IGNORE_DUPS
+setopt HIST_IGNORE_SPACE
+setopt HIST_REDUCE_BLANKS
+setopt HIST_SAVE_NO_DUPS
+setopt HIST_VERIFY
+setopt INC_APPEND_HISTORY
+setopt SHARE_HISTORY
+unsetopt HIST_BEEP
+
+export HISTIGNORE="ls:cd:cd -:pwd:exit:date:cal:* --help"
diff --git a/zsh/.zsh.d/30_completion.zsh b/zsh/.zsh.d/30_completion.zsh
new file mode 100644
index 0000000..bd720d1
--- /dev/null
+++ b/zsh/.zsh.d/30_completion.zsh
@@ -0,0 +1,77 @@
+#!/usr/bin/env zsh
+
+autoload -Uz compinit
+if [[ -s ${ZCOMPDUMP}(#qN.mh+12) && ( ! -s "${ZCOMPDUMP}.zwc" || "${ZCOMPDUMP}" -nt "${ZCOMPDUMP}.zwc" ) ]]
+then
+    compinit -d "${ZCOMPDUMP}"
+    zrecompile -pq "${ZCOMPDUMP}"
+else
+    compinit -d "${ZCOMPDUMP}" -C
+fi
+
+setopt AUTO_LIST
+setopt AUTO_MENU
+setopt AUTO_PARAM_KEYS
+setopt AUTO_PARAM_SLASH
+setopt COMPLETE_IN_WORD
+setopt EXTENDED_GLOB
+setopt HASH_LIST_ALL
+setopt LIST_PACKED
+setopt PATH_DIRS
+unsetopt CASE_GLOB
+unsetopt FLOW_CONTROL
+unsetopt MENU_COMPLETE
+
+zstyle ':completion:*' use-cache                on
+zstyle ':completion:*' cache-path               "${XDG_CACHE_HOME:-$HOME}/.zcompcache"
+
+zstyle ':completion:*'                          format '%F{blue}%d%f'
+zstyle ':completion:*:corrections'              format '%F{yellow}%d (errors: %e)%f'
+zstyle ':completion:*:descriptions'             format '%F{green}%d%f'
+zstyle ':completion:*:messages'                 format '%F{purple}%d%f'
+zstyle ':completion:*:warnings'                 format '%F{red}no matches found%f'
+
+zstyle ':completion:*:*:*:*:*'                  menu select
+zstyle ':completion:*:matches'                  group 'yes'
+zstyle ':completion:*:options'                  description 'yes'
+zstyle ':completion:*:options'                  auto-description '%d'
+zstyle ':completion:*:corrections'              format ' %F{green}-- %d (errors: %e) --%f'
+zstyle ':completion:*:descriptions'             format ' %F{yellow}-- %d --%f'
+zstyle ':completion:*:messages'                 format ' %F{purple} -- %d --%f'
+zstyle ':completion:*:warnings'                 format ' %F{red}-- no matches found --%f'
+zstyle ':completion:*:default'                  list-prompt '%S%M matches%s'
+zstyle ':completion:*'                          format ' %F{yellow}-- %d --%f'
+zstyle ':completion:*'                          group-name ''
+zstyle ':completion:*'                          verbose yes
+zstyle ':completion:*'                          matcher-list 'm:{a-zA-Z}={A-Za-z}' 'r:|=*' 'l:|=* r:|=*'
+
+zstyle ':completion:*'                          squeeze-slashes true
+zstyle ':completion:*:default'                  list-colors ${(s.:.)LS_COLORS}
+zstyle ':completion:*:*:cd:*'                   tag-order local-directories directory-stack path-directories
+zstyle ':completion:*:*:cd:*:directory-stack'   menu yes select
+zstyle ':completion:*:-tilde-:*'                group-order 'named-directories' 'path-directories' 'users' 'expand'
+
+zstyle ':completion:*'                          completer _complete _match _approximate
+zstyle ':completion:*:match:*'                  original only
+zstyle ':completion:*:approximate:*'            max-errors 1 numeric
+
+zstyle ':completion:*:functions'                ignored-patterns '(_*|pre(cmd|exec))'
+
+zstyle ':completion:*:history-words'            stop yes
+zstyle ':completion:*:history-words'            remove-all-dups yes
+zstyle ':completion:*:history-words'            list false
+zstyle ':completion:*:history-words'            menu yes
+
+zstyle ':completion::*:(-command-|export):*'    fake-parameters ${${${_comps[(I)-value-*]#*,}%%,*}:#-*-}
+
+zstyle ':completion:*:(rm|kill|diff):*'         ignore-line other
+zstyle ':completion:*:rm:*'                     file-patterns '*:all-files'
+
+zstyle ':completion:*:*:*:*:processes'          command 'ps -u ${LOGNAME} -o pid,user,command -w'
+zstyle ':completion:*:*:kill:*:processes'       list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;36=0=01'
+zstyle ':completion:*:*:kill:*'                 menu yes select
+zstyle ':completion:*:*:kill:*'                 force-list always
+zstyle ':completion:*:*:kill:*'                 insert-ids single
+
+zstyle ':completion:*:manuals'                  separate-sections true
+zstyle ':completion:*:manuals.(^1*)'            insert-sections true
diff --git a/zsh/.zsh.d/40_keybindings.zsh b/zsh/.zsh.d/40_keybindings.zsh
new file mode 100644
index 0000000..1be223d
--- /dev/null
+++ b/zsh/.zsh.d/40_keybindings.zsh
@@ -0,0 +1,3 @@
+#!/usr/bin/env zsh
+
+bindkey '^[[Z'  reverse-menu-complete   # M-TAB
diff --git a/zsh/.zsh.d/50_colors.zsh b/zsh/.zsh.d/50_colors.zsh
new file mode 100644
index 0000000..bc122a6
--- /dev/null
+++ b/zsh/.zsh.d/50_colors.zsh
@@ -0,0 +1,3 @@
+#!/usr/bin/env zsh
+
+autoload -U colors && colors
diff --git a/zsh/.zsh.d/60_prompt.zsh b/zsh/.zsh.d/60_prompt.zsh
new file mode 100644
index 0000000..4b07a2c
--- /dev/null
+++ b/zsh/.zsh.d/60_prompt.zsh
@@ -0,0 +1,6 @@
+#!/usr/bin/env zsh
+
+precmd ()
+{
+    PROMPT="%{$fg[green]%}%~%{$reset_color%} %{$fg_bold[green]%}λ%{$reset_color%} "
+}
diff --git a/zsh/.zsh.d/80_plugins.zsh b/zsh/.zsh.d/80_plugins.zsh
new file mode 100644
index 0000000..dbabba3
--- /dev/null
+++ b/zsh/.zsh.d/80_plugins.zsh
@@ -0,0 +1,32 @@
+#!/usr/bin/env zsh
+
+if [ "${TERM}" != "linux" ]
+then
+    ZGENOM_DIR="${HOME}/.zsh.d/zgenom"
+
+    if [ ! -d "${ZGENOM_DIR}" ]
+    then
+        git clone "https://github.com/jandamm/zgenom.git" "${ZGENOM_DIR}"
+    fi
+
+    source "${ZGENOM_DIR}/zgenom.zsh"
+    if ! zgen saved
+    then
+        zgenom load hlissner/zsh-autopair
+
+        zgenom load zsh-users/zsh-autosuggestions
+
+        zgenom load zsh-users/zsh-history-substring-search
+
+        zgenom load zsh-users/zsh-syntax-highlighting
+
+        zgenom load zsh-users/zsh-completions
+
+        zgenom load jeffreytse/zsh-vi-mode
+
+        zgenom save
+    fi
+
+    # zsh-users/zsh-autosuggestions
+    bindkey '^ ' autosuggest-accept
+fi
diff --git a/zsh/.zsh.d/90_external.zsh b/zsh/.zsh.d/90_external.zsh
new file mode 100644
index 0000000..bc79027
--- /dev/null
+++ b/zsh/.zsh.d/90_external.zsh
@@ -0,0 +1,6 @@
+#!/usr/bin/env zsh
+
+# https://github.com/garabik/grc {{{
+[[ -s "/usr/share/grc/grc.zsh" ]] && \
+    source /usr/share/grc/grc.zsh
+# }}}
diff --git a/zsh/.zshenv b/zsh/.zshenv
new file mode 100644
index 0000000..e4be411
--- /dev/null
+++ b/zsh/.zshenv
@@ -0,0 +1,18 @@
+#!/usr/bin/env zsh
+
+skip_global_compinit=1
+
+setopt NO_GLOBAL_RCS
+
+export ZDOTDIR="${HOME}"
+export ZCOMPDUMP="${ZDOTDIR}/.zsh.d/.zcompdump"
+export ZLOGIN="${ZDOTDIR}/.zlogin"
+export ZLOGOUT="${ZDOTDIR}/.zlogout"
+export ZPROFILE="${ZDOTDIR}/.zprofile"
+export ZSHENV="${ZDOTDIR}/.zshenv"
+export ZSHRC="${ZDOTDIR}/.zshrc"
+
+if [[ "${SHLVL}" -eq 1 && ! -o LOGIN && -s "${ZPROFILE}" ]]
+then
+    source "${ZPROFILE}"
+fi
diff --git a/zsh/.zshrc b/zsh/.zshrc
new file mode 100644
index 0000000..a66d52e
--- /dev/null
+++ b/zsh/.zshrc
@@ -0,0 +1,12 @@
+#!/usr/bin/env zsh
+
+if [[ $TERM == "dumb" ]]; then
+    unsetopt zle
+    return
+fi
+
+for i in "${HOME}"/.zsh.d/*.zsh
+do
+    [[ -r "$i" ]] && . "$i"
+done
+unset i
diff --git a/zsh/@install b/zsh/@install
new file mode 100755
index 0000000..daf7ad6
--- /dev/null
+++ b/zsh/@install
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+[ ! -d "${HOME}/.zsh.d" ] &&
+    mkdir -p "${HOME}/.zsh.d"
+
+stow \
+    --target="${HOME}" \
+    --ignore="^@.*" \
+    --verbose \
+    zsh

Consider giving Nix/NixOS a try! <3