From 52b054a2d2001f4fbd692954e716582e205a8b91 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 2 Feb 2020 15:24:04 +0100 Subject: [PATCH] Refactor zsh and sh rcs --- .gitignore | 80 ++------------------------------------- sh/.config/sh/alias | 14 ++++--- sh/.config/sh/env | 4 +- zsh/.config/zsh/.p10k.zsh | 16 ++++---- zsh/.config/zsh/.zshrc | 27 +++++++------ 5 files changed, 37 insertions(+), 104 deletions(-) diff --git a/.gitignore b/.gitignore index 9efe5c9..c790943 100644 --- a/.gitignore +++ b/.gitignore @@ -1,80 +1,6 @@ -*/.netrwhist -**/gopass-logo-small.png - -# Created by https://www.gitignore.io/api/vim,linux -# Edit at https://www.gitignore.io/?templates=vim,linux - -### Linux ### -*~ - -# temporary files which can be created if a process still has a handle open of a deleted file -.fuse_hidden* - -# KDE directory preferences -.directory - -# Linux trash folder which might appear on any partition or disk -.Trash-* - -# .nfs files are created when an open file is removed but is still being accessed -.nfs* - -### Vim ### -# Swap -[._]*.s[a-v][a-z] -[._]*.sw[a-p] -[._]s[a-rt-v][a-z] -[._]ss[a-gi-z] -[._]sw[a-p] - -# Session -Session.vim -Sessionx.vim - -# Temporary -.netrwhist - -# Auto-generated tag files -tags - -# Persistent undo -[._]*.un~ - -# Coc configuration directory -.vim - -### Zsh ### -# Zsh compiled script + zrecompile backup -*.zwc -*.zwc.old - -# Zsh completion-optimization dumpfile -*zcompdump* - -# Zsh zcalc history -.zcalc_history - -# A popular plugin manager's files -._zplugin -.zplugin_lstupd - -# zdharma/zshelldoc tool's files -zsdoc/data - -# robbyrussell/oh-my-zsh/plugins/per-directory-history plugin's files -# (when set-up to store the history in the local directory) -.directory_history - -# MichaelAquilina/zsh-autoswitch-virtualenv plugin's files -# (for Zsh plugins using Python) -.venv - -# Zunit tests' output -/tests/_output/* -!/tests/_output/.gitkeep - -# End of https://www.gitignore.io/api/vim,linux,zsh - +# no idea why gopass adds this image to config path +gopass-logo-small.png +# # Ignore dynamic colorschemes set by styler colorscheme.vim colorscheme diff --git a/sh/.config/sh/alias b/sh/.config/sh/alias index c3a37cd..daf913f 100644 --- a/sh/.config/sh/alias +++ b/sh/.config/sh/alias @@ -52,6 +52,8 @@ if exist git; then alias gd='git diff' alias gds='git diff --staged' + alias gi='git ignore' + alias glog='git log --stat' alias glg='git log --oneline --decorate --graph' alias glga='git log --oneline --decorate --graph --remotes --all' @@ -66,7 +68,7 @@ if exist git; then alias grv='git remote -v' alias grs='git restore --staged' - alias grss='git restore' + alias grs!='git restore' alias grbi='git rebase -i' alias grbc='git rebase --continue' @@ -94,9 +96,11 @@ if exist fzf; then # Display fuzzy-searchable history alias fzf_history="history | fzf --tac --height 20" # Fuzzy search packages to install - alias fzf_yay="yay -Slq | fzf -m --preview 'yay -Si {1}' | xargs -ro yay -S" - # Fuzzy uninstall packages - alias fzf_yayrns="yay -Qeq | fzf -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns" + if exist yay; then + alias fzf_yay="yay -Slq | fzf -m --preview 'yay -Si {1}' | xargs -ro yay -S" + # Fuzzy uninstall packages + alias fzf_yayrns="yay -Qeq | fzf -m --preview 'yay -Qi {1}' | xargs -ro yay -Rns" + fi fi # vifm @@ -106,5 +110,3 @@ if exist vifm; then # enable picture preview script exist vifmrun && alias vifm=vifmrun fi - -unset -f exist diff --git a/sh/.config/sh/env b/sh/.config/sh/env index 9b3737a..af817db 100644 --- a/sh/.config/sh/env +++ b/sh/.config/sh/env @@ -40,5 +40,5 @@ export GOPATH="$HOME/projects/gopath/" export PATH="$PATH:$GOPATH/bin" ## LANG LOCALE UTF-8 -export LC_ALL="en_US.utf-8" -export LANG="en_US.utf-8" +export LC_ALL="en_US.UTF-8" +export LANG="en_US.UTF-8" diff --git a/zsh/.config/zsh/.p10k.zsh b/zsh/.config/zsh/.p10k.zsh index 1edecff..a1422a8 100644 --- a/zsh/.config/zsh/.p10k.zsh +++ b/zsh/.config/zsh/.p10k.zsh @@ -348,7 +348,7 @@ # Untracked files icon. It's really a question mark, your font isn't broken. # Change the value of this parameter to show a different icon. - typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='?' + typeset -g POWERLEVEL9K_VCS_UNTRACKED_ICON='…' POWERLEVEL9K_VCS_UNTRACKED_ICON=${(g::)POWERLEVEL9K_VCS_UNTRACKED_ICON} # Formatter for Git status. @@ -409,19 +409,19 @@ res+="${meta}:${clean}${(V)VCS_STATUS_REMOTE_BRANCH//\%/%%}" # escape % fi - # ⇣42 if behind the remote. - (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}⇣${VCS_STATUS_COMMITS_BEHIND}" - # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. + # ⇣42 if behind the remote. customized to ↓ + (( VCS_STATUS_COMMITS_BEHIND )) && res+=" ${clean}↓${VCS_STATUS_COMMITS_BEHIND}" + # ⇡42 if ahead of the remote; no leading space if also behind the remote: ⇣42⇡42. ch to ↑ (( VCS_STATUS_COMMITS_AHEAD && !VCS_STATUS_COMMITS_BEHIND )) && res+=" " - (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}⇡${VCS_STATUS_COMMITS_AHEAD}" + (( VCS_STATUS_COMMITS_AHEAD )) && res+="${clean}↑${VCS_STATUS_COMMITS_AHEAD}" # *42 if have stashes. - (( VCS_STATUS_STASHES )) && res+=" ${clean}*${VCS_STATUS_STASHES}" + (( VCS_STATUS_STASHES )) && res+=" ${clean}⚑${VCS_STATUS_STASHES}" # 'merge' if the repo is in an unusual state. [[ -n $VCS_STATUS_ACTION ]] && res+=" ${conflicted}${VCS_STATUS_ACTION}" # ~42 if have merge conflicts. - (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}~${VCS_STATUS_NUM_CONFLICTED}" + (( VCS_STATUS_NUM_CONFLICTED )) && res+=" ${conflicted}✖${VCS_STATUS_NUM_CONFLICTED}" # +42 if have staged changes. - (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}+${VCS_STATUS_NUM_STAGED}" + (( VCS_STATUS_NUM_STAGED )) && res+=" ${modified}●${VCS_STATUS_NUM_STAGED}" # !42 if have unstaged changes. (( VCS_STATUS_NUM_UNSTAGED )) && res+=" ${modified}!${VCS_STATUS_NUM_UNSTAGED}" # ?42 if have untracked files. It's really a question mark, your font isn't broken. diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index aaf7f05..21cd645 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,6 +1,9 @@ #!/usr/bin/env zsh # +CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}" +ZSHCONFDIR="$CONFDIR/zsh" + # Set completion style # The following lines were added by compinstall zstyle ':completion:*' completer _complete _ignored _approximate @@ -8,7 +11,7 @@ zstyle ':completion:*' list-colors '' 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 '/home/marty/.config/zsh/.zshrc' +zstyle :compinstall filename "$ZSHCONFDIR/.zshrc" # End of lines added by compinstall autoload -Uz compinit zmv compinit @@ -22,13 +25,13 @@ fi # load all plugins -[ -f "$XDG_CONFIG_HOME/zsh/plugins.zsh" ] && source "$XDG_CONFIG_HOME/zsh/plugins.zsh" +[ -f "$ZSHCONFDIR/plugins.zsh" ] && source "$ZSHCONFDIR/plugins.zsh" # shellcheck source=alias -[ -f "$XDG_CONFIG_HOME/sh/alias" ] && source "$XDG_CONFIG_HOME/sh/alias" +[ -f "$CONFDIR/sh/alias" ] && source "$CONFDIR/sh/alias" # load additional aliases -if [ -d "$XDG_CONFIG_HOME/sh/alias.d" ]; then - for _alias in "$XDG_CONFIG_HOME/sh/alias.d"/*.sh; do +if [ -d "$CONFDIR/sh/alias.d" ]; then + for _alias in "$CONFDIR/sh/alias.d"/*.sh; do . "$_alias" done unset _alias @@ -44,7 +47,7 @@ ENABLE_CORRECTION="true" # Speed up autocomplete, force prefix mapping zstyle ':completion:*' accept-exact '*(N)' zstyle ':completion:*' use-cache on -zstyle ':completion:*' cache-path ~/.zsh/cache +zstyle ':completion:*' cache-path "${XDG_CACHE_HOME:-$HOME/.cache}/zshcompcache" # shellcheck disable=SC2016 zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)*==34=34}:${(s.:.)LS_COLORS}")' @@ -67,6 +70,7 @@ export HISTSIZE=100000 export SAVEHIST=100000 export HISTFILE="$XDG_DATA_HOME/zsh_history" export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help" + ## Set ZSH History aliases # Show the top 5 commands used in recent history history_top() { @@ -89,11 +93,7 @@ bindkey " " globalias bindkey "^ " magic-space # control-space to bypass completion bindkey -M isearch " " magic-space # normal space during searches -# To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh. -[[ ! -f "$XDG_CONFIG_HOME"/zsh/.p10k.zsh ]] || source "$XDG_CONFIG_HOME"/zsh/.p10k.zsh - -# In case a plugin adds a redundant path entry, remove duplicate entries -# from PATH +# Deduplicate PATH - remove any duplicate entries from PATH # from: https://unix.stackexchange.com/questions/40749/remove-duplicate-path-entries-with-awk-command get_var() { eval 'printf "%s\n" "${'"$1"'}"' @@ -110,3 +110,8 @@ dedup_pathvar() { dedup_pathvar PATH dedup_pathvar MANPATH +# To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh. +[[ ! -f "$ZSHCONFDIR/.p10k.zsh" ]] || source "$ZSHCONFDIR/.p10k.zsh" + +unset CONFDIR +unset ZSHCONFDIR