From 8eb81f95a10b12c52faa4fcdeb1e4941f02e3050 Mon Sep 17 00:00:00 2001 From: sev Date: Tue, 13 Oct 2020 01:00:57 -0500 Subject: [PATCH 1/1] refactored zsh configs, commented gpg-agent.conf zsh: - added vim modeline and site-local import to every file - added .zlogin following the above - moved arrows prompt to subdirectory - updated arrows prompt to make right mode look better - moved everything out of .zshenv, it never should have went there - moved interactive content to .zshrc and set-once content to .zprofile - updated application loading (perl, gpg) --- base/.zlogin | 4 ++ base/.zlogout | 5 ++ base/.zprofile | 62 +++++++++++++++++-- .../Prompts}/prompt_arrows_setup | 6 +- base/.zshenv | 48 +------------- base/.zshrc | 19 +++--- gpg/gpg-agent.conf | 3 +- 7 files changed, 81 insertions(+), 66 deletions(-) create mode 100644 base/.zlogin rename base/.zsh/{ => functions/Prompts}/prompt_arrows_setup (96%) diff --git a/base/.zlogin b/base/.zlogin new file mode 100644 index 0000000..6fbf574 --- /dev/null +++ b/base/.zlogin @@ -0,0 +1,4 @@ +### load site-specific +if [[ -f ~/.zlogin.local ]] { source ~/.zlogin.local } + +# vim: set et sts=4 sw=4 ts=8 tw=79 : diff --git a/base/.zlogout b/base/.zlogout index 249979e..9e0ed3f 100644 --- a/base/.zlogout +++ b/base/.zlogout @@ -1,2 +1,7 @@ echo logout clear + +### load site-specific +if [[ -f ~/.zlogout.local ]] { source ~/.zlogout.local } + +# vim: set et sts=4 sw=4 ts=8 tw=79 : diff --git a/base/.zprofile b/base/.zprofile index aa57163..82e70e4 100644 --- a/base/.zprofile +++ b/base/.zprofile @@ -1,15 +1,65 @@ -#XXX: ensure we override /etc/profile, gets loaded after .zshenv -source ~/.zshenv +### general exports +export EDITOR=vim +export PAGER=less +## lang +export CHARSET=UTF-8 +export LANG="en_US.UTF-8" +export LC_CTYPE="$LANG" +## histfile +export HISTFILE=~/.histfile +export HISTSIZE=1000 +export SAVEHIST=1000 +## path +# /usr/{pkg,local,games} are unix/bsdisms +typeset -U PATH path +path=({~/,/,/usr/}sbin {~/,/,/usr/}bin /usr/pkg/{s,}bin /usr/X11R{7,6}/bin + /usr/local/{s,}bin /usr/games "${path[@]}") +export PATH +typeset -U FPATH fpath +fpath=(~/.zsh/functions/Prompts "${fpath[@]}") +export FPATH +### applications +## python +export PYTHONSTARTUP=~/.pythonrc +## perl +(( ${+commands[perl]} )) && eval $(perl -I $XDG_DATA_HOME/perl5/lib/perl5 -Mlocal::lib=$XDG_DATA_HOME/perl5 2>/dev/null) +## gpg +if (( ${+commands[gpg]} )) { + # SSH_AUTH_SOCK should be set in a remote SSH session for passthrough + # if it isn't, we are likely the first login shell on the local machine + if [[ ! -v SSH_AUTH_SOCK ]] { + export GPG_TTY=$(tty) + gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null + export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) + } +} +## xdg +export XDG_CONFIG_HOME=~/etc +export XDG_CONFIG_DIRS=~/.config:/usr/pkg/etc/xdg:/usr/local/etc/xdg:/etc/xdg +export XDG_DATA_HOME=~/share +export XDG_DATA_DIRS=~/.local/share:/usr/pkg/share:/usr/local/share:/usr/share +export XDG_CACHE_HOME=~/tmp +export XDG_RUNTIME_DIR=~/tmp +## grep +# XXX: deprecated in GNU +export GREP_OPTIONS=--color=auto + +### tmp t="${TMPDIR:-/tmp}/home-$LOGNAME" h="$HOME/tmp" if [[ ! -e "$t" ]] { - mkdir -m 700 "$t" > /dev/null 2>&1 - #TODO: check if dir exists after mkdir + mkdir -m 700 "$t" > /dev/null 2>&1 + #TODO: check if dir exists after mkdir } -#allow opaque entries to override +#allow opaque entries to override link creation if [[ ! -e "$h" ]] { - ln -sf "$t" "$h" > /dev/null 2>&1 + ln -sf "$t" "$h" > /dev/null 2>&1 } unset t unset h + +### load site-specific +if [[ -f ~/.zprofile.local ]] { source ~/.zprofile.local } + +# vim: set et sts=4 sw=4 ts=8 tw=79 : diff --git a/base/.zsh/prompt_arrows_setup b/base/.zsh/functions/Prompts/prompt_arrows_setup similarity index 96% rename from base/.zsh/prompt_arrows_setup rename to base/.zsh/functions/Prompts/prompt_arrows_setup index 7dc4a90..77313c0 100644 --- a/base/.zsh/prompt_arrows_setup +++ b/base/.zsh/functions/Prompts/prompt_arrows_setup @@ -56,7 +56,7 @@ function prompt_arrows_setup() { ;; right) RPROMPT="$dirvcs $clock" - PROMPT="" + PROMPT="%F{$c}>>> " ;; *) echo "Unknown prompt mode $m" @@ -65,6 +65,7 @@ function prompt_arrows_setup() { } PROMPT="$PROMPT%(1j,%F{$c}%j,)$vicol%#%F{$p}%n%F{$n}@%F{$p}%2m%(?..%F{$n}/%F{$r}\$?)%F{$n}: " POSTEDIT="`print -P "%F{$n}%f"`" + autoload -Uz vcs_info zstyle ':vcs_info:git*' formats "%c%u%%F{$p}%r/%b%%F{$n}/%%F{$d}%S%%f" zstyle ':vcs_info:git*' actionformats "%%F{$r}(%a)%f %c%u%%F{$p}%r/%b%f/%%F{$d}%S%f" zstyle ':vcs_info:git*' stagedstr "%F{$c}+" @@ -83,7 +84,6 @@ function zle-line-init { } function prompt_arrows_precmd { - # TODO: check if vcs_info is autoloaded vcs_info } @@ -92,4 +92,4 @@ function prompt_arrows_preexec { } prompt_arrows_setup "$@" -# vim: set et fenc=utf-8 ft=zsh sts=4 sw=4 ts=8 tw=0 : +# vim: set et fenc=utf-8 ft=zsh sts=4 sw=4 ts=8 tw=0 : diff --git a/base/.zshenv b/base/.zshenv index 9fa140f..2ed1fc8 100644 --- a/base/.zshenv +++ b/base/.zshenv @@ -1,46 +1,4 @@ -### path -# /usr/{pkg,local,games} are unix/bsdisms -typeset -U path -path=({~/,/,/usr/}sbin {~/,/,/usr/}bin /usr/pkg/{s,}bin /usr/X11R{7,6}/bin - /usr/local/{s,}bin /usr/games $path) - -### posix -export EDITOR=vim -export PAGER=less -export GREP_OPTIONS=--color=auto -export LANG="en_US.UTF-8" -export LC_CTYPE="$LANG" - -### xdg -export XDG_CONFIG_HOME=~/etc -export XDG_CONFIG_DIRS=~/.config:/usr/pkg/etc/xdg:/usr/local/etc/xdg:/etc/xdg -export XDG_DATA_HOME=~/share -export XDG_DATA_DIRS=~/.local/share:/usr/pkg/share:/usr/local/share:/usr/share -export XDG_CACHE_HOME=~/tmp -export XDG_RUNTIME_DIR=~/tmp - -### applications -export PYTHONSTARTUP=~/.pythonrc -## perl -(( ${+commands[perl]} )) && eval $(perl -I $XDG_DATA_HOME/perl5/lib/perl5 -Mlocal::lib=$XDG_DATA_HOME/perl5) -## gpg -if (( ${+commands[gpg]} )) { - export GPG_TTY=$(tty) - if [[ ! -v SSH_AUTH_SOCK ]] { - # set up SSH auth socket and start GPG agent - export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) - } - gpg-connect-agent updatestartuptty /bye >/dev/null -} - -### freebsd -if [[ "$OSTYPE" =~ "^freebsd" ]] { - export CLICOLOR= - export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30' -} - ### load site-specific -if [[ -f ~/.zshenv.local ]] && [[ ! -v _ZSHENV_LOADED ]] { - export _ZSHENV_LOADED= - source ~/.zshenv.local -} +if [[ -f ~/.zshenv.local ]] { source ~/.zshenv.local } + +# vim: set et sts=4 sw=4 ts=8 tw=79 : diff --git a/base/.zshrc b/base/.zshrc index 1f6e987..412c5ba 100644 --- a/base/.zshrc +++ b/base/.zshrc @@ -1,9 +1,6 @@ ### imports source ~/bin/.check-busybox -### user-local fpath -fpath=(~/.zsh ~/.zsh/functions/Prompts "${fpath[@]}") - ### options setopt NO_BEEP NO_CLOBBER ## cd @@ -18,9 +15,6 @@ setopt PROMPT_SUBST setopt AUTO_CONTINUE ## history setopt NO_HIST_SAVE_BY_COPY HIST_IGNORE_DUPS SHARE_HISTORY -HISTFILE=~/.histfile -HISTSIZE=1000 -SAVEHIST=1000 ### keys bindkey -v @@ -132,6 +126,10 @@ case "$OSTYPE"; in bindkey "^[[F" end-of-line #End bindkey -a "^[[F" end-of-line + # colors + export CLICOLOR= + export LS_COLORS='di=34:ln=35:so=32:pi=33:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30' + ## sound function s { sysctl hw.snd.default_unit${1:+\=$1} } alias vol mixer @@ -186,7 +184,6 @@ zstyle ':vcs_info:git*:dotfiles' check-for-changes true zstyle ':vcs_info:git*' check-for-staged-changes true ## compinit -# The following lines were added by compinstall zstyle ':completion:*' auto-description '[arg] %d' zstyle ':completion:*' expand suffix zstyle ':completion:*' format '# %d' @@ -203,15 +200,15 @@ zstyle ':completion:*' select-prompt '%B%l%b' zstyle ':completion:*' verbose true zstyle :compinstall filename '/home/ds6/.zshrc' -autoload -Uz compinit -compinit -# End of lines added by compinstall +autoload -Uz compinit && compinit ## prompt -# do this last so prompt can potentially override +# do this last so prompt can potentially override other settings autoload -Uz promptinit && promptinit prompt arrows +### load site-specific +if [[ -f ~/.zshrc.local ]] { source ~/.zshrc.local } ### unset imports unfunction check-busybox diff --git a/gpg/gpg-agent.conf b/gpg/gpg-agent.conf index 7b6f994..513e54c 100644 --- a/gpg/gpg-agent.conf +++ b/gpg/gpg-agent.conf @@ -1,3 +1,4 @@ +# support ssh with gpg-agent enable-ssh-support -default-cache-ttl 0 +# try to use X11 pinentry if possible pinentry-program /usr/bin/pinentry-x11 -- 2.47.0