diff --git a/shell/aliases.sh b/shell/aliases.sh index 28dce4a9..d62b2362 100644 --- a/shell/aliases.sh +++ b/shell/aliases.sh @@ -1,5 +1,5 @@ # -# These aliases will be common to Bash and Zsh shells +# These aliases are common to Bash and Zsh shells # alias q='exit' diff --git a/shell/common.sh b/shell/common.sh index 9b3d2bfb..a77185d1 100644 --- a/shell/common.sh +++ b/shell/common.sh @@ -1,5 +1,3 @@ -#!/usr/bin/env bash - CACHE_DIR="$DOTFILES/shell/zsh/cache" is-callable() { command -v "$1" >/dev/null; } @@ -11,10 +9,10 @@ info() { printf "\r[ \033[00;34m..\033[0m ] $1\n"; } success() { printf "\r\033[2K[ \033[00;32mOK\033[0m ] $1\n"; } fail() { printf "\r\033[2K[\033[0;31mFAIL\033[0m] $1\n"; echo; exit; } -load () { source "$DOTFILES/$*"; } +load () { source "$DOTFILES/$1"; } loadall () { - for file in "$DOTFILES"/$1/*.zsh; do + for file in "$DOTFILES"/.enabled.d/${1//\//_}/${2:-*.*sh}; do source "$file" done } @@ -41,4 +39,4 @@ repo() { } # -umask 077 +load shell/env.sh diff --git a/shell/env.sh b/shell/env.sh new file mode 100644 index 00000000..25c4e7c2 --- /dev/null +++ b/shell/env.sh @@ -0,0 +1,11 @@ +# Loaded at the end of the initialization process + +export PATH="$DOTFILES/bin:$HOME/bin:$PATH" + +# +export EDITOR=$(is-callable nvim && echo 'nvim' || echo 'vim') +export VISUAL=$EDITOR + +# +export GPG_TTY=$(tty) +umask 077 diff --git a/shell/zsh/.zshenv b/shell/zsh/.zshenv index 643a5cdd..01c958c8 100644 --- a/shell/zsh/.zshenv +++ b/shell/zsh/.zshenv @@ -1,15 +1,18 @@ export DOTFILES="$HOME/.dotfiles" - source "$DOTFILES/shell/common.sh" ## Paths # Ensure path arrays do not contain duplicates. typeset -gU cdpath fpath mailpath path +path=(/usr/local/{,s}bin $path) + +load shell/env.sh +loadall shell/zsh env.zsh + path=( + $HOME/.bin $DOTFILES/bin - $HOME/bin - /usr/local/{,s}bin $path ) @@ -18,11 +21,9 @@ fpath=( $fpath ) -export EDITOR=$(is-callable nvim && echo 'nvim' || echo 'vim') -export VISUAL=$EDITOR export LESS='-g -i -M -R -S -w -z-4' if is-callable lesspipe; then export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-' fi -[[ -z "$LANG" ]] && export LANG='en_US.UTF-8' +[[ $LANG ]] || export LANG='en_US.UTF-8' diff --git a/shell/zsh/.zshrc b/shell/zsh/.zshrc index 08e28bae..0801a2f7 100644 --- a/shell/zsh/.zshrc +++ b/shell/zsh/.zshrc @@ -1,10 +1,17 @@ -### zshrc -# +#!/usr/bin/env zsh +# zshrc # By Henrik Lissner -# repo "tarjoilija/zgen" "$HOME/.zgen" +load shell/zsh/aliases.zsh +load shell/zsh/config.zsh +if is-interactive; then + load shell/zsh/completion.zsh + load shell/zsh/keybinds.zsh + load shell/zsh/prompt.zsh +fi + source "$HOME/.zgen/zgen.zsh" if ! zgen saved; then info "Creating zgen save" @@ -22,12 +29,4 @@ fi [[ -f "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local" -for file in $DOTFILES/.enabled.d/*; do - [[ -d "$file/bin" ]] && export PATH="$file/bin:$PATH" - - for script in $file/*.zsh; do - source "$script" - done -done - # Done! diff --git a/shell/zsh/completion.zsh b/shell/zsh/completion.zsh index ab732293..bf2b4fef 100644 --- a/shell/zsh/completion.zsh +++ b/shell/zsh/completion.zsh @@ -1,5 +1,3 @@ -is-interactive || exit - ## Options setopt COMPLETE_IN_WORD # Complete from both ends of a word. setopt PATH_DIRS # Perform path search even on command names with slashes. diff --git a/shell/zsh/keybinds.zsh b/shell/zsh/keybinds.zsh index 7b0b85cd..a6023caa 100644 --- a/shell/zsh/keybinds.zsh +++ b/shell/zsh/keybinds.zsh @@ -1,5 +1,3 @@ -is-interactive || exit - # Ran into an issue where the surround module wasn't working if KEYTIMEOUT is <= 10. # Specifically, (delete|change)-surround immediately abort into insert mode if # KEYTIMEOUT <= 8, and if <= 10, then add-surround would do the same. At 11, all these diff --git a/shell/zsh/prompt.zsh b/shell/zsh/prompt.zsh index 28372229..a54116a0 100644 --- a/shell/zsh/prompt.zsh +++ b/shell/zsh/prompt.zsh @@ -1,7 +1,6 @@ +#!/usr/bin/env zsh # Based off Pure -is-interactive || exit - _strlen() { echo ${#${(S%%)1//$~%([BSUbfksu]|([FB]|){*})/}}; } # fastest possible way to check if repo is dirty diff --git a/shell/zsh/update b/shell/zsh/update old mode 100644 new mode 100755