From 5c71eca6d717020376972c5cc3c56093a8a1f939 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Wed, 25 May 2022 15:44:49 -0500 Subject: feat(shell): fully impliment XDG spec and reorganize rc files --- bash/.bashrc | 8 ++++--- bash/.profile | 59 ++++++++++++++++++++++++++++++++++---------------- zsh/.config/zsh/.zshrc | 48 ++++++++++++++++++++-------------------- zsh/.zshenv | 59 ++++++++++++++++++++++++++++++++++---------------- 4 files changed, 110 insertions(+), 64 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index 0eb8bf0..7d454d7 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -1,5 +1,7 @@ #!/usr/bin/bash +export HISTFILE=$XDG_STATE_HOME/bash/history + # Aliases alias ls='ls --color=tty' alias l='ls -lah' @@ -27,9 +29,9 @@ alias dct="docker context" alias dcu="docker context use" if [[ $- == *i* ]] && [ -d "$BASHCOMPDIR" ]; then - for f in "$BASHCOMPDIR"/*; do - source "$f" - done + for f in "$BASHCOMPDIR"/*; do + source "$f" + done fi command -v starship >/dev/null 2>&1 && source <(starship init bash) diff --git a/bash/.profile b/bash/.profile index 2b0f9c7..cd002f5 100644 --- a/bash/.profile +++ b/bash/.profile @@ -1,30 +1,51 @@ -# XDG -export XDG_CONFIG_HOME="$HOME"/.config -export XDG_CACHE_HOME="$HOME"/.cache -export XDG_DATA_HOME="$HOME"/.local/share +#!/usr/bin/env bash + +# https://wiki.archlinux.org/title/XDG_Base_Directory +export XDG_CONFIG_HOME=$HOME/.config +export XDG_CACHE_HOME=$HOME/.cache +export XDG_DATA_HOME=$HOME/.local/share +export XDG_STATE_HOME=$HOME/.local/state export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/"$UID"} -# Shell -export ZDOTDIR="$XDG_CONFIG_HOME"/zsh -export BASH_COMPLETION_USER_DIR="$XDG_DATA_HOME"/bash-completion/completions +export ZDOTDIR=$XDG_CONFIG_HOME/zsh +export BASH_COMPLETION_USER_DIR=$XDG_DATA_HOME/bash-completion/completions +export LESSHISTFILE=$XDG_STATE_HOME/lesshst +export WGETRC=$XDG_CONFIG_HOME/wgetrc -# Misc -export EDITOR="$( command -v nvim 2>/dev/null || command -v vim 2>/dev/null || command -v vi )" +export EDITOR="$(command -v nvim 2>/dev/null || command -v vim 2>/dev/null || command -v vi)" export BROWSER="firefox" export TERMINAL="alacritty" export MANPAGER="sh -c 'col -bx | bat -l man -p'" export MANROFFOPT="-c" -export GOPATH="$XDG_DATA_HOME"/go export STARSHIP_LOG="error" -export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always {} || cat {} || tree -C {}" +export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always {} || cat {} || exa --tree --icons --git-ignore {} || tree -C {}" export FZF_DEFAULT_COMMAND="fd --type f || git ls-tree -r --name-only HEAD || rg --files || find ." -export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +export FZF_DEFAULT_OPTS='--exit-0 --select-1 --bind "q:abort,ctrl-y:preview-up,ctrl-e:preview-down,ctrl-u:preview-half-page-up,ctrl-d:preview-half-page-down,ctrl-b:preview-page-up,ctrl-f:preview-page-down,alt-up:half-page-up,alt-down:half-page-down"' +export FZF_CTRL_T_COMMAND=$FZF_DEFAULT_COMMAND export FZF_CTRL_T_OPTS="--min-height 30 --preview-window down:60% --preview-window noborder --preview '($FZF_PREVIEW_COMMAND) 2> /dev/null'" -# Path -export PATH="$PATH":"$HOME"/.local/bin -export PATH="$PATH":"$HOME"/.scripts -export PATH="$PATH":"$HOME"/.go/bin -export PATH="$PATH":"$HOME"/.dotnet/tools -export PATH="$PATH":"$HOME"/.cargo/bin -export PATH="$PATH":/usr/local/texlive/2021/bin/x86_64-linux +export PATH=$PATH:$HOME/.local/bin + +# rust +export RUSTUP_HOME=$XDG_DATA_HOME/rustup +export CARGO_HOME=$XDG_DATA_HOME/cargo +export PATH=$PATH:$CARGO_HOME/bin + +# go +export GOPATH=$XDG_DATA_HOME/go +export PATH=$PATH:$GOPATH/bin + +# npm +export npm_config_userconfig=$XDG_CONFIG_HOME/npm/config +export npm_config_cache=$XDG_CACHE_HOME/npm +export npm_config_prefix=$XDG_DATA_HOME/npm +export PATH=$PATH:$npm_config_prefix/bin + +# dotnet +export DOTNET_CLI_HOME=$XDG_DATA_HOME/dotnet +export PATH=$PATH:$DOTNET_CLI_HOME/tools + +# texlive +export TEXMFHOME=$XDG_DATA_HOME/texmf +export TEXMFVAR=$XDG_CACHE_HOME/texlive/texmf-var +export TEXMFCONFIG=$XDG_CONFIG_HOME/texlive/texmf-config diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc index fbe8f5c..aa47fe7 100644 --- a/zsh/.config/zsh/.zshrc +++ b/zsh/.config/zsh/.zshrc @@ -1,10 +1,9 @@ -# Opts -HYPHEN_INSENSITIVE="true" -DISABLE_UPDATE_PROMPT="true" -DISABLE_AUTO_TITLE="true" -HISTFILE=~/.zsh_history -HISTSIZE=10000 -SAVEHIST=10000 +export HYPHEN_INSENSITIVE="true" +export DISABLE_UPDATE_PROMPT="true" +export DISABLE_AUTO_TITLE="true" +export HISTFILE=$XDG_STATE_HOME/zsh/history +export HISTSIZE=10000 +export SAVEHIST=10000 setopt no_beep setopt menu_complete @@ -17,16 +16,8 @@ setopt hist_ignore_space # ignore commands that start with space setopt hist_verify # show command with history expansion to user before running it setopt share_history # share command history data -# Exports -typeset -A ZSH_HIGHLIGHT_STYLES -export ZSH_HIGHLIGHT_STYLES[path]='fg=cyan' -export ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern line) -export ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion) -# https://github.com/zsh-users/zsh-autosuggestions#suggestion-highlight-style -export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#4f4738" - +zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh/zcompcache -# Aliases alias ls='ls --color=tty' alias l='ls -lah' alias la='ls -lAh' @@ -38,6 +29,8 @@ alias ipa="ip -s -c -h a" alias untar="tar -zxvf" alias td=". td.sh" alias vim=nvim +alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"' +alias tlmgr='/usr/share/texmf-dist/scripts/texlive/tlmgr.pl --usermode' alias dexec="docker exec -it" alias dps="docker ps" alias dc="docker compose" @@ -52,7 +45,22 @@ alias dclf="docker compose logs -f" alias dct="docker context" alias dcu="docker context use" -# Misc +bindkey -e +bindkey '^ ' autosuggest-accept +bindkey '^[[Z' reverse-menu-complete +bindkey '^[[1~' beginning-of-line +bindkey '^[[4~' end-of-line +bindkey '^[[3~' delete-char +bindkey '^[[1;5C' forward-word +bindkey '^[[1;5D' backward-word + +# typeset -A ZSH_HIGHLIGHT_STYLES +# export ZSH_HIGHLIGHT_STYLES[path]='fg=cyan' +export ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern line) +export ZSH_AUTOSUGGEST_STRATEGY=(match_prev_cmd completion) +# https://github.com/zsh-users/zsh-autosuggestions#suggestion-highlight-style +export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#4f4738" + command -v fd &>/dev/null && _fzf_compgen_path() { fd --hidden --follow --exclude ".git" . "$1" } @@ -61,11 +69,5 @@ command -v fd &>/dev/null && _fzf_compgen_dir() { fd --type d --hidden --follow --exclude ".git" . "$1" } -# Keybinds -bindkey -e -bindkey '^ ' autosuggest-accept -bindkey '^[[Z' reverse-menu-complete - -# Prompt/plugins command -v starship &>/dev/null && source <(starship init zsh) command -v sheldon &>/dev/null && source <(sheldon source) diff --git a/zsh/.zshenv b/zsh/.zshenv index 2b0f9c7..cd002f5 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,30 +1,51 @@ -# XDG -export XDG_CONFIG_HOME="$HOME"/.config -export XDG_CACHE_HOME="$HOME"/.cache -export XDG_DATA_HOME="$HOME"/.local/share +#!/usr/bin/env bash + +# https://wiki.archlinux.org/title/XDG_Base_Directory +export XDG_CONFIG_HOME=$HOME/.config +export XDG_CACHE_HOME=$HOME/.cache +export XDG_DATA_HOME=$HOME/.local/share +export XDG_STATE_HOME=$HOME/.local/state export XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/run/user/"$UID"} -# Shell -export ZDOTDIR="$XDG_CONFIG_HOME"/zsh -export BASH_COMPLETION_USER_DIR="$XDG_DATA_HOME"/bash-completion/completions +export ZDOTDIR=$XDG_CONFIG_HOME/zsh +export BASH_COMPLETION_USER_DIR=$XDG_DATA_HOME/bash-completion/completions +export LESSHISTFILE=$XDG_STATE_HOME/lesshst +export WGETRC=$XDG_CONFIG_HOME/wgetrc -# Misc -export EDITOR="$( command -v nvim 2>/dev/null || command -v vim 2>/dev/null || command -v vi )" +export EDITOR="$(command -v nvim 2>/dev/null || command -v vim 2>/dev/null || command -v vi)" export BROWSER="firefox" export TERMINAL="alacritty" export MANPAGER="sh -c 'col -bx | bat -l man -p'" export MANROFFOPT="-c" -export GOPATH="$XDG_DATA_HOME"/go export STARSHIP_LOG="error" -export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always {} || cat {} || tree -C {}" +export FZF_PREVIEW_COMMAND="bat --style=numbers,changes --wrap never --color always {} || cat {} || exa --tree --icons --git-ignore {} || tree -C {}" export FZF_DEFAULT_COMMAND="fd --type f || git ls-tree -r --name-only HEAD || rg --files || find ." -export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +export FZF_DEFAULT_OPTS='--exit-0 --select-1 --bind "q:abort,ctrl-y:preview-up,ctrl-e:preview-down,ctrl-u:preview-half-page-up,ctrl-d:preview-half-page-down,ctrl-b:preview-page-up,ctrl-f:preview-page-down,alt-up:half-page-up,alt-down:half-page-down"' +export FZF_CTRL_T_COMMAND=$FZF_DEFAULT_COMMAND export FZF_CTRL_T_OPTS="--min-height 30 --preview-window down:60% --preview-window noborder --preview '($FZF_PREVIEW_COMMAND) 2> /dev/null'" -# Path -export PATH="$PATH":"$HOME"/.local/bin -export PATH="$PATH":"$HOME"/.scripts -export PATH="$PATH":"$HOME"/.go/bin -export PATH="$PATH":"$HOME"/.dotnet/tools -export PATH="$PATH":"$HOME"/.cargo/bin -export PATH="$PATH":/usr/local/texlive/2021/bin/x86_64-linux +export PATH=$PATH:$HOME/.local/bin + +# rust +export RUSTUP_HOME=$XDG_DATA_HOME/rustup +export CARGO_HOME=$XDG_DATA_HOME/cargo +export PATH=$PATH:$CARGO_HOME/bin + +# go +export GOPATH=$XDG_DATA_HOME/go +export PATH=$PATH:$GOPATH/bin + +# npm +export npm_config_userconfig=$XDG_CONFIG_HOME/npm/config +export npm_config_cache=$XDG_CACHE_HOME/npm +export npm_config_prefix=$XDG_DATA_HOME/npm +export PATH=$PATH:$npm_config_prefix/bin + +# dotnet +export DOTNET_CLI_HOME=$XDG_DATA_HOME/dotnet +export PATH=$PATH:$DOTNET_CLI_HOME/tools + +# texlive +export TEXMFHOME=$XDG_DATA_HOME/texmf +export TEXMFVAR=$XDG_CACHE_HOME/texlive/texmf-var +export TEXMFCONFIG=$XDG_CONFIG_HOME/texlive/texmf-config -- cgit v1.2.3-70-g09d2