shell: refactor + polish
This commit is contained in:
parent
fcc4be6eb6
commit
ba11030eae
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
11
shell/env.sh
Normal file
11
shell/env.sh
Normal file
|
@ -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
|
|
@ -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'
|
||||
|
|
|
@ -1,10 +1,17 @@
|
|||
### zshrc
|
||||
#
|
||||
#!/usr/bin/env zsh
|
||||
# zshrc
|
||||
# By Henrik Lissner <henrik@lissner.net>
|
||||
#
|
||||
|
||||
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!
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Based off Pure <https://github.com/sindresorhus/pure>
|
||||
|
||||
is-interactive || exit
|
||||
|
||||
_strlen() { echo ${#${(S%%)1//$~%([BSUbfksu]|([FB]|){*})/}}; }
|
||||
|
||||
# fastest possible way to check if repo is dirty
|
||||
|
|
0
shell/zsh/update
Normal file → Executable file
0
shell/zsh/update
Normal file → Executable file
Loading…
Reference in a new issue