From: Huck Boles Date: Sun, 28 May 2023 16:01:30 +0000 (-0500) Subject: merged: desktop X-Git-Url: https://git.huck.website/?a=commitdiff_plain;h=efa5a2c74a2eab2bb69205348e7e57c222d3bb8b;p=zsh.git merged: desktop --- diff --git a/.gitignore b/.gitignore index e92ea9b..ed5fc63 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ !.zshenv !.zprofile !include/ +!completions/ diff --git a/.zshenv b/.zshenv index 1f3ea56..2286211 100644 --- a/.zshenv +++ b/.zshenv @@ -1,6 +1,3 @@ -# terminfo -[[ $TERM = "tmux-256color" ]] && export TERM=screen-256color - # xdg variables export XDG_CONFIG_HOME="$HOME/.config" export XDG_DATA_HOME="$HOME/.local/share" @@ -9,9 +6,11 @@ export XDG_CACHE_HOME="$HOME/.local/cache" # shell variables export SHELL="/bin/zsh" -export ZDOTDIR="$HOME/.config/zsh" export ZSH="$ZDOTDIR" -export ZSH_CUSTOM="$ZSH/custom" +export ZSHEXTRA="$ZDOTDIR/extra" +export ZSHINCLUDE="$ZDOTDIR/include" +export ZSHCOMPLETION="$ZSH/completions" +export ZSHHISTORY="$ZSH/history" export ZSH_COMPDUMP="$ZSH/cache/.zcompdump-$HOST" # my folders @@ -20,13 +19,13 @@ export DOTFILES="$REPOS/dotfiles" export SCRIPTS="$REPOS/script" export DOWNLOADS="$HOME/downloads" export PACKAGES="$HOME/.packages" +export CONFIG="$XDG_CONFIG_HOME" # system variables export LANG=en_US.UTF-8 # path variables -export PATH="$PATH:$HOME/.local/bin:." -export PATH="$PATH:$REPOS/script:$REPOS/ruby" +export PATH="$PATH:$HOME/.local/bin:$REPOS/script:$REPOS/ruby:." export CDPATH=".:$HOME:$HOME/$REPOS:$HOME/$XDG_CONFIG_HOME:/" # language variables @@ -48,9 +47,12 @@ export BROWSER="/usr/bin/firefox" export EMAIL='huck@huck.website' # config paths +export GTK_2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" export LESSHISTFILE="$XDG_STATE_HOME/less/history" export TERMINFO="$XDG_DATA_HOME/terminfo" +export TERMINFO_DIRS="$XDG_DATA_HOME/terminfo:/usr/share/terminfo" export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" +export CUDA_CACHE_PATH="$XDG_CACHE_HOME/nv" # zoxide export _ZO_ECHO='1' diff --git a/.zshrc b/.zshrc index de10c66..f4e4fbb 100644 --- a/.zshrc +++ b/.zshrc @@ -1,18 +1,10 @@ #shellcheck disable=all -# sourcing ------------------------------------------------- -. $ZSH/.zshenv -ZSHEXTRA=$ZSH/extra -ZSHINCLUDE=$ZSH/include -[[ ! -d $ZSH ]] && mkdir $ZSH/{,cache,extra,include} -# source files from include dir -for file in $ZSHINCLUDE/*; do . ${file}; done - -# start programs -[[ -f $XDG_CONFIG_HOME/.dircolors ]] && eval $(dircolors -b $XDG_CONFIG_HOME/.dircolors) -[[ $(which zoxide) ]] && eval "$(zoxide init zsh --cmd z)" +# setup ~/.config/zsh +. $ZDOTDIR/.zshenv +[[ ! -d $ZSH ]] && mkdir -p $ZSH/cache $ZSHINCLUDE $ZSHCOMPLETION $ZSHEXTRA $ZSHHISTORY -# options ------------------------------------------------------------ +# options ENABLE_CORRECTION="true" COMPLETION_WAITING_DOTS="true" HISTFILE=$ZSH/history/zsh-history @@ -36,46 +28,26 @@ setopt auto_param_keys auto_param_slash auto_remove_slash setopt null_glob glob glob_dots glob_star_short bang_hist unsetopt flow_control -# completion --------------------------------------------------------- -zstyle ':completion:*' auto-description '%d' -zstyle ':completion:*' completer _expand _complete _ignored _correct _approximate -zstyle ':completion:*' completions 1 -zstyle ':completion:*' expand prefix suffix -zstyle ':completion:*' file-sort access -zstyle ':completion:*' format '%d' -zstyle ':completion:*' glob 1 -zstyle ':completion:*' group-name '' -zstyle ':completion:*' ignore-parents parent pwd -zstyle ':completion:*' insert-unambiguous true -zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} -zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s -zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'r:|[._-,]=** r:|=**' 'l:|=* r:|=*' -zstyle ':completion:*' max-errors 3 -zstyle ':completion:*' menu select=long interactive -zstyle ':completion:*' original true -zstyle ':completion:*' prompt '%e' -zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s -zstyle ':completion:*' squeeze-slashes true -zstyle ':completion:*' substitute 1 -zstyle ':completion:*' verbose true +# completion +fpath=($ZSHCOMPLETION $fpath) +[[ -f $ZSHCOMPLETION/completions.zsh ]] && source $ZSHCOMPLETION/completions.zsh + +# source files from include dir +for file in $ZSHINCLUDE/*; do . ${file}; done -autoload -Uz compinit -for dump in ~/.zcompdump(N.mh+24); do - compinit -done -compinit -C -zshcache_time="$(date +%s%N)" +# start programs +[[ -f $XDG_CONFIG_HOME/.dircolors ]] && eval $(dircolors -b $XDG_CONFIG_HOME/.dircolors) +[[ $(which zoxide) ]] && eval "$(zoxide init zsh --cmd z)" -# zle plugins ------------------------------------------------------- +# zle plugins autoload -Uz chpwd_recent_dirs cdr add-zsh-hook +autoload -Uz run-help add-zsh-hook chpwd chpwd_recent_dirs chpwd() { ls -Ah } -autoload -Uz run-help - -# keybindings ------------------------------------------------------- +# keybindings bindkey "\e[1~" beginning-of-line bindkey "\e[4~" end-of-line bindkey "\e[5~" beginning-of-history @@ -83,12 +55,12 @@ bindkey "\e[6~" end-of-history bindkey "\e[3~" delete-char bindkey "\e[2~" quoted-insert -# custom prompt ----------------------------------------------------- +# custom prompt if [[ -n $SSH_CONNECTION ]]; then PROMPT='%(?..%B%F{red}x) -%B%F{yellow}%n%b%f@%B%F{blue}%M%b%f -> %F{green}%d %F{red}[SSH] %B%F{magenta}[gentoo]%b%f $(git_prompt_enhanced_status) +%B%F{yellow}%n%b%f@%B%F{red}%m%b%f: %F{blue}%~ %F{red}[SSH] %F{magenta}[gentoo] %f$(git_prompt_enhanced_status) %B%F{green}%(!.#.$) %f%b> ' -RPROMPT='[%!]' +RPROMPT='%f[%!]' else PROMPT='%(?..%B%F{red}x) %B%F{green}%n%b%f@%B%F{red}%m%b%f: %F{blue}%~ %f$(git_prompt_enhanced_status) diff --git a/completions/completions.zsh b/completions/completions.zsh new file mode 100644 index 0000000..60437f3 --- /dev/null +++ b/completions/completions.zsh @@ -0,0 +1,43 @@ +LIST_PACKED=true +GLOB_COMPLETE=true + +zstyle ':completion:*' completer _expand _extensions _complete _approximate +zstyle ':completion:*' completions true +zstyle ':completion:*' expand prefix suffix +zstyle ':completion:*' insert-unambiguous true +zstyle ':completion:*' max-errors 3 + +zstyle ':completion:*' file-sort time follow +zstyle ':completion:*' file-list all + +zstyle ':completion:*' path-completion true +zstyle ':completion:*' glob true +zstyle ':completion:*' group-name '' +zstyle ':completion:*' ignore-parents parent pwd +zstyle ':completion:*' substitute true +zstyle ':completion:*' squeeze-slashes true + +zstyle ':completion:*' menu select=long search +zstyle ':completion:*' original true +zstyle ':completion:*' verbose true +zstyle ':completion:*' prompt '%e' +zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s +zstyle ':completion:*' matcher-list '' 'm:{[:lower:]}={[:upper:]}' 'r:|[._-,]=** r:|=**' 'l:|=* r:|=*' + +zstyle ':completion:*' gain-privileges true + +zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS} +zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s + +zstyle ':completion:*' auto-description '%d' +zstyle ':completion:*:*:*:*:descriptions' format '%F{green}-- %d --%f' +zstyle ':completion:*:corrections' format '%F{yellow}!- %d -!%f' +zstyle ':completion:*:warnings' format '%F{red}no matches%f' +zstyle ':completion:*:messages' format '%F{blue}== %d ==%f' + +autoload -Uz compinit +for dump in ~/.zcompdump(N.mh+24); do + compinit +done +compinit -C +zshcache_time="$(date +%s%N)" diff --git a/include/aliases.zsh b/include/aliases.zsh index 15f9ce9..6a6c44a 100644 --- a/include/aliases.zsh +++ b/include/aliases.zsh @@ -1,53 +1,47 @@ -#shell aliases alias cp='cp -vr' alias rm='rm -v' alias mv='mv -v' alias mkdir='mkdir -pv' alias mount='mount --mkdir' alias lsblk='lsblk -f' + alias reload='source $ZSH/.zshrc' alias quit='disown -a && exit' alias :q='exit' -# vim aliases alias v='nvim' alias vsesh='nvim -S' alias vdiff='nvim -d' -# sudo aliases alias sv='sudoedit' -alias sudo='sudo ' +alias sudo="sudo " -# convinience aliases alias ..='cd ..' alias ...='cd ../..' alias ....='cd ../../..' + alias h='history 0' alias j='jobs -l' alias c='clear' -alias zc='cd; clear' +alias zc='cd;clear' + +alias cd='z ' + alias dust='dust -rb' alias xz='xz -v -T0 -9 -M64G' alias make='make CFLAGS="-march=sandybridge -O2 -pipe" -j48 -l30' -# ls aliases alias ls='lsd' alias l='ls' -alias la='l -Ah' -alias ll='la -l' -alias lt='l --tree' +alias ll='ls -lAh' +alias la='ls -Ah' +alias lt='ls --tree' -# color aliases alias ip='ip --color=auto' alias grep='grep --color=auto' -alias fgrep='fgrep --color=auto' -alias egrep='egrep --color=auto' -# tmux aliases -alias tmux='tmux' alias tattach='tmux attach-session -t' -# docker aliases alias d='docker' alias dr='docker run -d --rm' alias dc='docker compose up -d --remove-orphans' @@ -56,3 +50,5 @@ alias drm='docker rm' alias drs='docker restart' alias de='docker exec -it' alias dlog='docker logs --timestamps --follow -n20' +# config aliases +alias wget='wget --hsts-file="$XDG_DATA_HOME/wget-hsts"' diff --git a/include/functions.zsh b/include/functions.zsh index 624e3b3..2d8a789 100644 --- a/include/functions.zsh +++ b/include/functions.zsh @@ -1,12 +1,9 @@ #!/bin/bash -# grep through history -hg() { history 0 | grep "$1"; } - # easy find files -f() { find . | grep "$1"; } - -cd() { z $1; ls } +f() { + find . | grep "$1"; +} # smart remove rem() { diff --git a/include/plugins.zsh b/include/plugins.zsh index b81330b..c9e4207 100644 --- a/include/plugins.zsh +++ b/include/plugins.zsh @@ -1,16 +1,25 @@ -if [[ -d $ZSHEXTRA/zsh-autosuggestions ]]; then - source $ZSHEXTRA/zsh-autosuggestions/zsh-autosuggestions.zsh - ZSH_AUTOSUGGEST_STRATEGY=(history completion) - set ZSH_AUTOSUGGEST_USE_ASYNC +# fish like autosuggestions +if [[ ! -d $ZSHEXTRA/zsh-autosuggestions ]]; then + cd $ZSHEXTRA + git clone 'https://github.com/zsh-users/zsh-autosuggestions' "$ZSHEXTRA/zsh-autosuggestions" fi +source "$ZSHEXTRA/zsh-autosuggestions/zsh-autosuggestions.zsh" +ZSH_AUTOSUGGEST_STRATEGY=(history completion) +set ZSH_AUTOSUGGEST_USE_ASYNC -if [[ -d $ZSHEXTRA/zsh-fast-syntax-highlighting ]]; then - source $ZSHEXTRA/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh - fast-theme -q $ZSH/extra/zsh-fast-syntax-highlighting/themes/custom.ini +# syntax highlighing +if [[ ! -d $ZSHEXTRA/zsh-fast-syntax-highlighting ]]; then + cd $ZSHEXTRA + git clone 'https://github.com/zdharma-continuum/fast-syntax-highlighting' "$ZSHEXTRA/zsh-fast-syntax-highlighting" fi +source $ZSHEXTRA/zsh-fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh +fast-theme -q $ZSH/extra/zsh-fast-syntax-highlighting/themes/custom.ini -if [[ -d $ZSHEXTRA/zsh-history-substring-search ]]; then - source $ZSHEXTRA/zsh-history-substring-search/zsh-history-substring-search.zsh - bindkey '^[[A' history-substring-search-up - bindkey '^[[B' history-substring-search-down +# up arrow history search of partial commands +if [[ ! -d $ZSHEXTRA/zsh-history-substring-search ]]; then + cd $ZSHEXTRA + git clone 'https://github.com/zsh-users/zsh-history-substring-search' fi +source $ZSHEXTRA/zsh-history-substring-search/zsh-history-substring-search.zsh "$ZSHEXTRA/zsh-history-substring-search" +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down