Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
#!/usr/bin/env zsh
|
|
|
|
#
|
|
|
|
|
|
|
|
CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}"
|
|
|
|
ZSHCONFDIR="$CONFDIR/zsh"
|
|
|
|
|
2021-08-25 18:47:07 +00:00
|
|
|
# load completion, extended zsh moving syntax, zle edit in vim (or other $EDITOR) possibility
|
|
|
|
autoload -Uz compinit zmv edit-command-line promptinit
|
|
|
|
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
# Set completion style
|
|
|
|
# The following lines were added by compinstall
|
|
|
|
zstyle ':completion:*' completer _complete _ignored _approximate
|
|
|
|
zstyle ':completion:*' matcher-list '' '+m:{[:lower:]}={[:upper:]} r:|[._-]=** r:|=**'
|
|
|
|
zstyle ':completion:*' menu select=1
|
|
|
|
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
|
|
|
zstyle :compinstall filename "$ZSHCONFDIR/.zshrc"
|
2021-08-25 18:47:07 +00:00
|
|
|
compinit
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
# End of lines added by compinstall
|
2020-02-08 15:28:36 +00:00
|
|
|
|
|
|
|
# load plugins
|
2023-01-10 14:37:45 +00:00
|
|
|
[ -e /usr/share/oh-my-zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh ] && source /usr/share/oh-my-zsh/plugins/colored-man-pages/colored-man-pages.plugin.zsh
|
|
|
|
[ -e /usr/share/oh-my-zsh/plugins/command-not-found/command-not-found.plugin.zsh ] && source /usr/share/oh-my-zsh/plugins/command-not-found/command-not-found.plugin.zsh
|
|
|
|
[ -e /usr/share/fzf/key-bindings.zsh ] && source /usr/share/fzf/key-bindings.zsh
|
2021-02-19 11:45:36 +00:00
|
|
|
#source /usr/share/nvm/init-nvm.sh
|
2022-12-08 12:31:07 +00:00
|
|
|
## find the correct installed tab-completion version
|
2023-01-10 14:37:45 +00:00
|
|
|
PLUG_FOLDER="/usr/share/zsh/plugins"
|
2020-06-19 22:12:39 +00:00
|
|
|
[ -e $PLUG_FOLDER/fzf-tab/fzf-tab.plugin.zsh ] && source $PLUG_FOLDER/fzf-tab/fzf-tab.plugin.zsh
|
2022-12-08 12:31:07 +00:00
|
|
|
[ -e $PLUG_FOLDER/fzf-tab-bin-git/fzf-tab.plugin.zsh ] && source $PLUG_FOLDER/fzf-tab-bin-git/fzf-tab.plugin.zsh
|
2020-06-19 22:12:39 +00:00
|
|
|
# these need to be sourced after fzf-tab
|
|
|
|
[ -e $PLUG_FOLDER/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh ] && source $PLUG_FOLDER/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh
|
2022-12-08 12:31:07 +00:00
|
|
|
[ -e $PLUG_FOLDER/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source $PLUG_FOLDER/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
2020-06-19 22:12:39 +00:00
|
|
|
[ -e $PLUG_FOLDER/alias-tips/alias-tips.plugin.zsh ] && source $PLUG_FOLDER/alias-tips/alias-tips.plugin.zsh
|
|
|
|
[ -e $PLUG_FOLDER/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh ] && source $PLUG_FOLDER/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
|
|
|
|
unset PLUG_FOLDER
|
|
|
|
|
|
|
|
# simple fzf-tab settings
|
2022-07-08 21:54:39 +00:00
|
|
|
zstyle ":fzf-tab:*" fzf-flags "--ansi" "--expect='$continuous_trigger,$print_query'" "--color=hl:$(($#headers == 0 ? 108 : 255))" "--nth=2,3" "--layout=reverse" "--height=${FZF_TMUX_HEIGHT:-75%}" "--tiebreak=begin" "-m" "--bind=tab:down,btab:up,change:top,ctrl-space:toggle" "--cycle" "--query=$query" "--header-lines=$#headers" "--print-query"
|
|
|
|
|
|
|
|
zstyle ':fzf-tab:*' fzf-command fzf
|
2020-10-08 08:28:56 +00:00
|
|
|
# format colorful groups for different completion actions
|
|
|
|
zstyle ':completion:*:descriptions' format '[%d]'
|
2022-07-08 21:54:39 +00:00
|
|
|
zstyle ':fzf-tab:*' show-group brief
|
2020-10-08 08:28:56 +00:00
|
|
|
# use input as query string when completing zlua
|
|
|
|
zstyle ':fzf-tab:complete:_zlua:*' query-string input
|
|
|
|
# (experimental, may change in the future)
|
2020-06-19 22:12:39 +00:00
|
|
|
# some boilerplate code to define the variable `extract` which will be used later
|
2020-10-08 08:28:56 +00:00
|
|
|
# please remember to copy them
|
2020-06-19 22:12:39 +00:00
|
|
|
local extract="
|
|
|
|
# trim input(what you select)
|
|
|
|
local in=\${\${\"\$(<{f})\"%\$'\0'*}#*\$'\0'}
|
|
|
|
# get ctxt for current completion(some thing before or after the current word)
|
|
|
|
local -A ctxt=(\"\${(@ps:\2:)CTXT}\")
|
|
|
|
# real path
|
|
|
|
local realpath=\${ctxt[IPREFIX]}\${ctxt[hpre]}\$in
|
|
|
|
realpath=\${(Qe)~realpath}
|
|
|
|
"
|
|
|
|
# give a preview of commandline arguments when completing `kill`
|
|
|
|
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w"
|
|
|
|
zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap
|
|
|
|
# give a preview of directory by exa when completing cd
|
|
|
|
zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'exa -1 --color=always $realpath'
|
2020-02-08 15:28:36 +00:00
|
|
|
|
2021-02-19 11:45:36 +00:00
|
|
|
# pure prompt init
|
|
|
|
promptinit
|
|
|
|
# make it single line
|
|
|
|
prompt_newline='%666v'
|
2021-08-25 18:47:07 +00:00
|
|
|
# show git stash status as a ≡
|
|
|
|
zstyle :prompt:pure:git:stash show yes
|
2023-01-10 15:47:16 +00:00
|
|
|
# show hostname if we are in a distrobox environment
|
|
|
|
if [ -n "$DISTROBOX_ENTER_PATH" ] && [ -f /run/.containerenv ]; then
|
|
|
|
local container=lxc
|
|
|
|
fi
|
2021-08-25 18:47:07 +00:00
|
|
|
prompt pure
|
2021-02-19 11:45:36 +00:00
|
|
|
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
# shellcheck source=alias
|
|
|
|
[ -f "$CONFDIR/sh/alias" ] && source "$CONFDIR/sh/alias"
|
|
|
|
# load additional aliases
|
|
|
|
if [ -d "$CONFDIR/sh/alias.d" ]; then
|
2021-03-27 21:19:43 +00:00
|
|
|
for _alias in "$CONFDIR/sh/alias.d"/*.sh; do
|
2022-10-08 15:55:27 +00:00
|
|
|
source "$_alias"
|
2021-03-27 21:19:43 +00:00
|
|
|
done
|
|
|
|
unset _alias
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
fi
|
2023-06-20 10:58:53 +00:00
|
|
|
# shellcheck source=alias
|
|
|
|
[ -f "$ZSHCONFDIR/alias" ] && source "$ZSHCONFDIR/alias"
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
if [ -d "$ZSHCONFDIR/alias.d" ]; then
|
2021-03-27 21:19:43 +00:00
|
|
|
for _alias in "$ZSHCONFDIR/alias.d"/*.sh; do
|
2022-10-08 15:55:27 +00:00
|
|
|
source "$_alias"
|
2021-03-27 21:19:43 +00:00
|
|
|
done
|
|
|
|
unset _alias
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Correct spelling for commands
|
|
|
|
setopt correct
|
|
|
|
# turn off the infernal correctall for filenames
|
|
|
|
unsetopt correctall
|
|
|
|
# Enable command auto-correction.
|
|
|
|
ENABLE_CORRECTION="true"
|
2020-11-02 18:10:25 +00:00
|
|
|
# allow moving through directories without prepending cd
|
|
|
|
setopt autocd
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
|
2023-09-28 12:41:33 +00:00
|
|
|
eval "$(zoxide init zsh)"
|
|
|
|
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
# Speed up autocomplete, force prefix mapping
|
|
|
|
zstyle ':completion:*' accept-exact '*(N)'
|
|
|
|
zstyle ':completion:*' use-cache on
|
2020-02-02 22:32:37 +00:00
|
|
|
zstyle ':completion:*' cache-path "${XDG_CACHE_HOME:-$HOME/.cache}/zshcompcache"
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
|
|
|
|
### history
|
|
|
|
## Set ZSH History defaults
|
|
|
|
setopt append_history
|
2021-03-27 21:19:43 +00:00
|
|
|
setopt extended_history # record command start time
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
setopt hist_ignore_dups
|
2021-03-27 21:19:43 +00:00
|
|
|
setopt hist_ignore_all_dups # do not put duplicated command into history list
|
|
|
|
setopt hist_save_no_dups # do not save duplicated command
|
|
|
|
setopt hist_expire_dups_first
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
setopt hist_ignore_space
|
2021-03-27 21:19:43 +00:00
|
|
|
setopt hist_reduce_blanks # remove unnecessary blanks
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
setopt hist_verify
|
2021-03-27 21:19:43 +00:00
|
|
|
setopt inc_append_history_time # append command to history file immediately after execution
|
|
|
|
setopt share_history # Share your history across all your terminal windows
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
setopt pushd_ignore_dups
|
|
|
|
#setopt pushd_silent
|
2021-11-16 11:18:39 +00:00
|
|
|
export HISTSIZE=1000000
|
|
|
|
export SAVEHIST=1000000
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
export HISTFILE="$XDG_DATA_HOME/zsh_history"
|
2021-11-16 11:18:39 +00:00
|
|
|
export HISTORY_IGNORE="(jrnl *|l *|ls *|z *|cd *|cd -|pwd|pwd *|exit|date)"
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
|
|
|
|
## Set ZSH History aliases
|
|
|
|
# Show the top 5 commands used in recent history
|
|
|
|
history_top() {
|
2021-03-27 21:19:43 +00:00
|
|
|
history | awk "{a[\$2]++} END{for(i in a){printf \"%5d\t%s\n\",a[i],i}}" | sort -rn | head
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
}
|
|
|
|
# Display timestamped recent command history
|
|
|
|
alias history="fc -l -d -D"
|
|
|
|
|
|
|
|
### Glob Alias expansion
|
|
|
|
# Expand aliases inline - see http://blog.patshead.com/2012/11/automatically-expaning-zsh-global-aliases---simplified.html
|
|
|
|
globalias() {
|
2021-03-27 21:19:43 +00:00
|
|
|
if [[ $LBUFFER =~ [A-Z0-9]+$ ]]; then
|
|
|
|
zle _expand_alias
|
|
|
|
zle expand-word
|
|
|
|
fi
|
|
|
|
zle self-insert
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
}
|
|
|
|
zle -N globalias
|
|
|
|
bindkey " " globalias
|
|
|
|
bindkey "^ " magic-space # control-space to bypass completion
|
|
|
|
bindkey -M isearch " " magic-space # normal space during searches
|
|
|
|
|
2020-10-21 15:09:48 +00:00
|
|
|
# allow inserting previous arguments in the current zle input
|
|
|
|
# see https://stackoverflow.com/a/34861762
|
|
|
|
bindkey "^[." insert-last-word
|
|
|
|
|
2020-02-10 20:07:00 +00:00
|
|
|
# VIM MODE for the shell
|
|
|
|
# enable vim mode on pressing escape
|
|
|
|
bindkey -v
|
|
|
|
# remove the delay for switching modes
|
|
|
|
export KEYTIMEOUT=1
|
|
|
|
# space puts a space, even in cmd mode
|
|
|
|
bindkey -a ' ' magic-space
|
|
|
|
# always allow backspace/delete to remove letters
|
|
|
|
bindkey '^?' backward-delete-char
|
|
|
|
bindkey -a '^?' backward-delete-char
|
|
|
|
bindkey '^h' backward-delete-char
|
|
|
|
bindkey -a '^h' backward-delete-char
|
|
|
|
# and forward with delete
|
|
|
|
bindkey '^[[3~' delete-char
|
|
|
|
bindkey -a '^[[3~' delete-char
|
|
|
|
# always allow removing words with <c-w>
|
|
|
|
bindkey -a '^w' backward-kill-word
|
|
|
|
# enable cycling through previous commands with <c-p/n>
|
2020-11-06 14:08:47 +00:00
|
|
|
bindkey '^P' history-beginning-search-backward
|
|
|
|
bindkey '^N' history-beginning-search-forward
|
|
|
|
|
2020-02-10 20:07:00 +00:00
|
|
|
# search history backwards <c-r>
|
2022-07-08 21:50:10 +00:00
|
|
|
bindkey '^o' history-incremental-search-backward
|
2020-11-06 14:08:47 +00:00
|
|
|
# cycle through history results
|
|
|
|
bindkey -M isearch '^P' history-incremental-search-backward
|
|
|
|
bindkey -M isearch '^N' history-incremental-search-forward
|
2020-02-10 20:07:00 +00:00
|
|
|
|
2020-05-05 20:27:17 +00:00
|
|
|
# Send command to editor and back for execution
|
|
|
|
zle -N edit-command-line
|
2022-07-08 21:53:06 +00:00
|
|
|
bindkey '^e' edit-command-line
|
2022-10-08 15:55:27 +00:00
|
|
|
bindkey -M vicmd '^e' edit-command-line
|
2020-05-05 20:27:17 +00:00
|
|
|
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
# Deduplicate PATH - remove any duplicate entries from PATH
|
|
|
|
# from: https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command
|
|
|
|
get_var() {
|
2021-03-27 21:19:43 +00:00
|
|
|
eval 'printf "%s\n" "${'"$1"'}"'
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
}
|
|
|
|
set_var() {
|
2021-03-27 21:19:43 +00:00
|
|
|
eval "$1=\"\$2\""
|
Add basic XDG compliant sh architecture
The only file left in $HOME is .zshenv, which sets up zsh to source everything from XDG_CONFIG_HOME/zsh.
Shell files are split into sh and zsh directories, for global assignments (which should be posix compliant, work on any posix shell) like environemnt variables, xdg vars, and global aliases. zsh contains zsh specific customization (prompt customization, plugin loading, zsh completions).
Zsh initialization will pull from sh directory first, loading the respective mirror to its startup file (`.zprofile` loads `sh/profile` and `profile.d/*`, `.zshenv` loads `sh/env` and `sh/env.d/*` and `zsh/env.d/*`, `.zshrc` loads `sh/alias`, `sh/alias.d/*` and `zsh/alias.d/*`)
Once all is done, it will have loaded both global variables, aliases and settings, and zsh-only specifications. Other stow modules, if they want to add shell functionality, can include their aliases and functions in one of the above directories to automatically be picked up by zsh.
2020-02-02 15:08:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unset CONFDIR
|
|
|
|
unset ZSHCONFDIR
|