feat(misc): add comprehensive Zsh configuration
Add new .zshrc with modern Zsh features, including plugins (fzf-tab, autosuggestions, syntax-highlighting, history-substring-search), custom key bindings, extended history settings, and streamlined alias definitions. New Features - Added `vim`, `code`, `edit` aliases pointing to `$EDITOR`. - Integrated fzf-tab with enhanced preview and theming. - Enabled autosuggestions, syntax highlighting, and substring history search. - Configured advanced completion, prefix highlighting, and tree/completion helpers. - Exported `VISUAL`, `EDITOR`, `BROWSER` and PATH settings. - Set up starship prompt with custom styling. Enhancements - Configured Zsh history settings for size, deduping, and sharing. - Added aliases for common commands (e.g., `l`, `lla`, `lt`, `update`, `upgrade`). - Introduced helper functions for virtualenv activation and git shortcuts. - Added tree and cat wrappers with icons and colors. - Added utility aliases for cleanup, cache management, and session switching.
This commit is contained in:
2 files changed
+232
-3
No files matched your search
@@ -1,3 +0,0 @@
|
||||
ZDOTDIR="$HOME/.config/zsh"
|
||||
|
||||
# vim:ft=zsh
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
[[ $- != *i* ]] && return
|
||||
|
||||
# ┬ ┬┌─┐┬─┐┌─┐
|
||||
# └┐┌┘├─┤├┬┘└─┐
|
||||
# └┘ ┴ ┴┴└─└─┘
|
||||
|
||||
export VISUAL="${EDITOR}"
|
||||
export EDITOR='nvim'
|
||||
export BROWSER='zen-browser'
|
||||
export HISTORY_IGNORE="(ls|cd|pwd|exit|sudo reboot|history|cd -|cd ..)"
|
||||
export SUDO_PROMPT="Deploying root access for %u. Password pls: "
|
||||
export BAT_THEME="base16"
|
||||
|
||||
if [ -d "$HOME/.local/bin" ] ;
|
||||
then PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
|
||||
# ┬ ┌─┐┌─┐┌┬┐ ┌─┐┌┐┌┌─┐┬┌┐┌┌─┐
|
||||
# │ │ │├─┤ ││ ├┤ ││││ ┬││││├┤
|
||||
# ┴─┘└─┘┴ ┴─┴┘ └─┘┘└┘└─┘┴┘└┘└─┘
|
||||
autoload -Uz compinit
|
||||
|
||||
local zcompdump="$HOME/.config/zsh/zcompdump"
|
||||
|
||||
if [[ -n "$zcompdump"(#qN.mh+24) ]]; then
|
||||
compinit -i -d "$zcompdump"
|
||||
else
|
||||
compinit -C -d "$zcompdump"
|
||||
fi
|
||||
|
||||
if [[ ! -f "${zcompdump}.zwc" || "$zcompdump" -nt "${zcompdump}.zwc" ]]; then
|
||||
zcompile -U "$zcompdump"
|
||||
fi
|
||||
|
||||
|
||||
autoload -Uz add-zsh-hook
|
||||
autoload -Uz vcs_info
|
||||
precmd () { vcs_info }
|
||||
_comp_options+=(globdots)
|
||||
|
||||
zstyle ':completion:*' menu select
|
||||
zstyle ':completion:*:descriptions' format '[%d]'
|
||||
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
|
||||
zstyle ':completion:*' matcher-list \
|
||||
'm:{a-zA-Z}={A-Za-z}' \
|
||||
'+r:|[._-]=* r:|=*' \
|
||||
'+l:|=*'
|
||||
zstyle ':vcs_info:*' formats ' %B%s-[%F{magenta}%f %F{yellow}%b%f]-'
|
||||
zstyle ':fzf-tab:*' fzf-flags --style=full --height=90% --pointer '>' \
|
||||
--color 'pointer:green:bold,bg+:-1:,fg+:green:bold,info:blue:bold,marker:yellow:bold,hl:gray:bold,hl+:yellow:bold' \
|
||||
--input-label ' Search ' --color 'input-border:blue,input-label:blue:bold' \
|
||||
--list-label ' Results ' --color 'list-border:green,list-label:green:bold' \
|
||||
--preview-label ' Preview ' --color 'preview-border:magenta,preview-label:magenta:bold'
|
||||
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --icons=always --color=always -a $realpath'
|
||||
zstyle ':fzf-tab:complete:eza:*' fzf-preview 'eza -1 --icons=always --color=always -a $realpath'
|
||||
zstyle ':fzf-tab:complete:bat:*' fzf-preview 'bat --color=always --theme=base16 $realpath'
|
||||
zstyle ':fzf-tab:*' fzf-bindings 'space:accept'
|
||||
zstyle ':fzf-tab:*' accept-line enter
|
||||
|
||||
# ┬ ┬┌─┐┬┌┬┐┬┌┐┌┌─┐ ┌┬┐┌─┐┌┬┐┌─┐
|
||||
# │││├─┤│ │ │││││ ┬ │││ │ │ └─┐
|
||||
# └┴┘┴ ┴┴ ┴ ┴┘└┘└─┘ ─┴┘└─┘ ┴ └─┘
|
||||
expand-or-complete-with-dots() {
|
||||
echo -n "\e[31m…\e[0m"
|
||||
zle expand-or-complete
|
||||
zle redisplay
|
||||
}
|
||||
zle -N expand-or-complete-with-dots
|
||||
bindkey "^I" expand-or-complete-with-dots
|
||||
|
||||
# ┬ ┬┬┌─┐┌┬┐┌─┐┬─┐┬ ┬
|
||||
# ├─┤│└─┐ │ │ │├┬┘└┬┘
|
||||
# ┴ ┴┴└─┘ ┴ └─┘┴└─ ┴
|
||||
HISTFILE=~/.config/zsh/zhistory
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
HISTDUP=erase
|
||||
setopt appendhistory
|
||||
setopt sharehistory
|
||||
setopt hist_ignore_space
|
||||
setopt hist_ignore_all_dups
|
||||
setopt hist_save_no_dups
|
||||
setopt hist_ignore_dups
|
||||
setopt hist_find_no_dups
|
||||
|
||||
# ┌─┐┌─┐┬ ┬ ┌─┐┌─┐┌─┐┬ ┌─┐┌─┐┌┬┐┬┌─┐┌┐┌┌─┐
|
||||
# ┌─┘└─┐├─┤ │ │ ││ ││ │ │├─┘ │ ││ ││││└─┐
|
||||
# └─┘└─┘┴ ┴ └─┘└─┘└─┘┴─┘ └─┘┴ ┴ ┴└─┘┘└┘└─┘
|
||||
setopt AUTOCD # change directory just by typing its name
|
||||
setopt PROMPT_SUBST # enable command substitution in prompt
|
||||
setopt MENU_COMPLETE # Automatically highlight first element of completion menu
|
||||
setopt LIST_PACKED # The completion menu takes less space.
|
||||
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
|
||||
setopt COMPLETE_IN_WORD # Complete from both ends of a word.
|
||||
|
||||
# ┌┬┐┬ ┬┌─┐ ┌─┐┬─┐┌─┐┌┬┐┌─┐┌┬┐
|
||||
# │ ├─┤├┤ ├─┘├┬┘│ ││││├─┘ │
|
||||
# ┴ ┴ ┴└─┘ ┴ ┴└─└─┘┴ ┴┴ ┴
|
||||
|
||||
export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship.toml"
|
||||
eval "$(starship init zsh)"
|
||||
|
||||
|
||||
# ┌─┐┬ ┬ ┬┌─┐┬┌┐┌┌─┐
|
||||
# ├─┘│ │ ││ ┬││││└─┐
|
||||
# ┴ ┴─┘└─┘└─┘┴┘└┘└─┘
|
||||
source /usr/share/zsh/plugins/fzf-tab-git/fzf-tab.zsh
|
||||
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
|
||||
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
|
||||
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
|
||||
|
||||
bindkey '^[[A' history-substring-search-up
|
||||
bindkey '^[[B' history-substring-search-down
|
||||
bindkey '^[[3~' delete-char
|
||||
bindkey "^[[H" beginning-of-line
|
||||
bindkey "^[[F" end-of-line
|
||||
|
||||
# ┌─┐┬ ┬┌─┐┌┐┌┌─┐┌─┐ ┌┬┐┌─┐┬─┐┌┬┐┬┌┐┌┌─┐┬ ┌─┐ ┌┬┐┬┌┬┐┬ ┌─┐
|
||||
# │ ├─┤├─┤││││ ┬├┤ │ ├┤ ├┬┘│││││││├─┤│ └─┐ │ │ │ │ ├┤
|
||||
# └─┘┴ ┴┴ ┴┘└┘└─┘└─┘ ┴ └─┘┴└─┴ ┴┴┘└┘┴ ┴┴─┘└─┘ ┴ ┴ ┴ ┴─┘└─┘
|
||||
function xterm_title_precmd () {
|
||||
print -Pn -- '\e]2;%n@%m %~\a'
|
||||
[[ "$TERM" == 'screen'* ]] && print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-}\e\\'
|
||||
}
|
||||
|
||||
function xterm_title_preexec () {
|
||||
print -Pn -- '\e]2;%n@%m %~ %# ' && print -n -- "${(q)1}\a"
|
||||
[[ "$TERM" == 'screen'* ]] && { print -Pn -- '\e_\005{g}%n\005{-}@\005{m}%m\005{-} \005{B}%~\005{-} %# ' && print -n -- "${(q)1}\e\\"; }
|
||||
}
|
||||
|
||||
if [[ "$TERM" == (kitty*|alacritty*|tmux*|screen*|xterm*) ]]; then
|
||||
add-zsh-hook -Uz precmd xterm_title_precmd
|
||||
add-zsh-hook -Uz preexec xterm_title_preexec
|
||||
fi
|
||||
|
||||
# ┌─┐┬ ┬┌─┐┌─┐
|
||||
# ├─┤│ │├─┤└─┐
|
||||
# ┴ ┴┴─┘┴┴ ┴└─┘
|
||||
|
||||
alias vim='$EDITOR'
|
||||
alias vi='$EDITOR'
|
||||
alias code='$EDITOR'
|
||||
alias edit='vim' # Edit files with vim
|
||||
|
||||
alias ls="eza --color=auto --icons"
|
||||
alias l="ls -l"
|
||||
alias ll="ls -a"
|
||||
alias lla="ls -la"
|
||||
alias lt="ls --tree"
|
||||
|
||||
#pacman unlock
|
||||
alias unlock="sudo rm /var/lib/pacman/db.lck"
|
||||
alias rmpacmanlock="sudo rm /var/lib/pacman/db.lck"
|
||||
|
||||
# aur helper
|
||||
alias i="paru -S"
|
||||
alias r="paru -Rns"
|
||||
alias u="paru -Syu"
|
||||
alias s="paru -Ss"
|
||||
alias Q="paru -Q"
|
||||
|
||||
#cache clean
|
||||
alias clean="paru -Scc"
|
||||
|
||||
# pacman or pm
|
||||
alias pacman='sudo pacman --color auto'
|
||||
alias update='sudo pacman -Syyu'
|
||||
alias upgrade='paru -Syyu'
|
||||
|
||||
#add new fonts
|
||||
alias update-fc='sudo fc-cache -fv'
|
||||
|
||||
#switch between bash and zsh
|
||||
alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'"
|
||||
alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'"
|
||||
alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'"
|
||||
|
||||
#fix obvious typo's
|
||||
alias c="clear"
|
||||
alias q="exit"
|
||||
alias :q="exit"
|
||||
alias mtar='tar -zcvf' # mtar <archive_compress>
|
||||
alias utar='tar -zxvf' # utar <archive_decompress> <file_list>
|
||||
alias z='zip -r' # z <archive_compress> <file_list>
|
||||
alias uz='unzip' # uz <archive_decompress> -d <dir>
|
||||
alias sr='source ~/.config/zsh/env.zsh'
|
||||
alias ..="cd .."
|
||||
alias mkdir="mkdir -p"
|
||||
alias cat="bat --color always --plain"
|
||||
alias grep='grep --color=auto'
|
||||
alias mv='mv -v'
|
||||
alias cp='cp -vr'
|
||||
alias rm='rm -vr'
|
||||
|
||||
|
||||
#clean caches
|
||||
alias cleanram="sudo sh -c 'sync; echo 3 > /proc/sys/vm/drop_caches'"
|
||||
|
||||
#grub update
|
||||
alias mkgrub='sudo grub-mkconfig -o /boot/grub/grub.cfg'
|
||||
|
||||
# other
|
||||
alias tree='tree -C'
|
||||
|
||||
# virtual env
|
||||
venv() {
|
||||
if [[ -d .venv ]]; then
|
||||
source .venv/bin/activate && echo "Activated existing .venv"
|
||||
else
|
||||
python -m venv .venv && source .venv/bin/activate && echo "Created and activated new .venv"
|
||||
fi
|
||||
}
|
||||
|
||||
act() {
|
||||
local dir="$PWD"
|
||||
while [[ "$dir" != "/" ]]; do
|
||||
if [[ -f "$dir/venv/bin/activate" ]]; then
|
||||
source "$dir/venv/bin/activate" && echo "Activated: $dir/venv"
|
||||
return
|
||||
elif [[ -f "$dir/.venv/bin/activate" ]]; then
|
||||
source "$dir/.venv/bin/activate" && echo "Activated: $dir/.venv"
|
||||
return
|
||||
fi
|
||||
dir="$(dirname "$dir")"
|
||||
done
|
||||
echo "No virtualenv found"
|
||||
}
|
||||
|
||||
# git Aliases
|
||||
alias commit="git add . && git commit -m"
|
||||
alias push="git push"
|
||||
Reference in new issue
Block a user