chore(config): zsh env settings reworking

This commit is contained in:
2023-07-27 14:19:37 +03:00
parent d7106ae28f
commit 4e2ee377f2
5 changed files with 63 additions and 50 deletions

View File

@@ -3,6 +3,9 @@
# this is my zsh config. there are many like it, but this one is mine.
# shellcheck shell=bash
export ZDOTDIR="$HOME/.local/state/zsh"
mkdir -p "$ZDOTDIR"
autoload -U colors zsh/terminfo
colors
setopt correct
@@ -10,6 +13,7 @@ setopt correct
# Add completion scripts to zsh path
FPATH="~/.config/zsh/completion:$FPATH"
autoload -Uz compinit && compinit -i
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
# Defaults
export DOTFILES="$HOME/.dotfiles"
@@ -52,5 +56,7 @@ have starship && eval "$(starship init zsh)"
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh ] \
&& source "${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf.zsh
export LESSHISTFILE="$XDG_CACHE_HOME"/less_history
# Fig post block. Keep at the bottom of this file.
[[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"

View File

@@ -84,3 +84,6 @@ if [[ -f "$HOME/.aliases.local" ]]; then
# shellcheck disable=SC1091
source "$HOME/.aliases.local"
fi
alias wget=wget --hsts-file="$XDG_DATA_HOME/wget-hsts"
alias svn="svn --config-dir $XDG_CONFIG_HOME/subversion"

View File

@@ -31,10 +31,7 @@ path_prepend "$XDG_BIN_HOME"
# brew, https://brew.sh
have brew && {
path_append "$(brew --prefix python)/bin"
path_append "$(brew --prefix coreutils)/libexec/gnubin"
path_append "$(brew --prefix ruby)/bin"
path_append "$(gem environment gemdir)/bin"
have_brew python && path_append "$(brew --prefix python)/bin"
}
source "$DOTFILES/config/exports-shell"

View File

@@ -13,42 +13,34 @@ export ANTIGEN_PLUGIN_RECEIPT_F=".local/share/antigen/antigen_plugin_lastupdate"
# Ansible configuration
# https://docs.ansible.com/ansible/latest/reference_appendices/config.html
export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible"
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible.cfg"
export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache"
have ansible && {
export ANSIBLE_HOME="$XDG_CONFIG_HOME/ansible"
export ANSIBLE_CONFIG="$XDG_CONFIG_HOME/ansible.cfg"
export ANSIBLE_GALAXY_CACHE_DIR="$XDG_CACHE_HOME/ansible/galaxy_cache"
x-dc "$ANSIBLE_HOME"
x-dc "$ANSIBLE_GALAXY_CACHE_DIR"
}
# brew configuration
have brew && {
FPATH="$(brew --prefix)/share/zsh/site-functions:${FPATH}"
autoload -Uz compinit
compinit
}
export ANDROID_HOME="$XDG_DATA_HOME/android"
# composer, https://getcomposer.org/
export COMPOSER_HOME="$XDG_STATE_HOME/composer"
export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin"
have composer && {
export COMPOSER_HOME="$XDG_STATE_HOME/composer"
export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin"
export PATH="$COMPOSER_BIN:$PATH"
}
# docker, https://docs.docker.com/engine/reference/commandline/cli/
export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
have docker && {
export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
x-dc "$DOCKER_CONFIG"
# Docker: Disable snyk ad
export DOCKER_SCAN_SUGGEST=false
}
# ffmpeg
have ffmpeg && {
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
x-dc "$FFMPEG_DATADIR"
}
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
have ffmpeg && x-dc "$FFMPEG_DATADIR"
# gcloud
have gcloud && {
@@ -57,20 +49,12 @@ have gcloud && {
[[ -f "$GCLOUD_LOC/completion.zsh.inc" ]] && builtin source "$GCLOUD_LOC/completion.zsh.inc"
}
# gem, rubygems
have gem && {
export GEM_HOME="$XDG_STATE_HOME/gem"
export GEM_PATH="$XDG_STATE_HOME/gem"
export PATH="$GEM_HOME/bin:$PATH"
path_append "$GEM_PATH/bin"
}
# GnuPG
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
# If we have go packages, include them to the PATH
have go && {
export GOPATH="$XDG_DATA_HOME/go"
export GOBIN="$XDG_BIN_HOME"
x-dc "$GOPATH"
}
# Go
export GOPATH="$XDG_DATA_HOME/go"
export GOBIN="$XDG_BIN_HOME"
# irssi
have irssi && {
@@ -81,10 +65,8 @@ have irssi && {
}
# nb, https://xwmx.github.io/nb/
have nb && {
export NB_DIR="$XDG_STATE_HOME/nb"
x-dc "$NB_DIR"
}
export NBRC_PATH="$XDG_CONFIG_HOME/nbrc"
export NB_DIR="$XDG_STATE_HOME/nb"
# nvm, the node version manager
export NVM_LAZY_LOAD=true
@@ -101,25 +83,40 @@ have node && {
}
# op (1Password cli) is present
export OP_CACHE="$XDG_STATE_HOME/1password"
have op && {
export OP_CACHE="$XDG_STATE_HOME/1password"
x-dc "$OP_CACHE"
eval "$(op completion zsh)"
compdef _op op
}
# Python
#
# pyenv, python environments
export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
export PYENV_ROOT="$XDG_STATE_HOME/pyenv"
have pyenv && {
export PYENV_ROOT="$XDG_STATE_HOME/pyenv"
x-dc "$PYENV_ROOT"
path_append "$PYENV_ROOT/bin"
eval "$(pyenv init -)"
}
have rbenv && {
eval "$(rbenv init - zsh)"
}
# Ruby
#
# including: bundler, rbenv
export GEM_HOME="${XDG_DATA_HOME}"/gem
export GEM_SPEC_CACHE="${XDG_CACHE_HOME}"/gem
export BUNDLE_USER_CONFIG="$XDG_CONFIG_HOME"/bundle
export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
export RBENV_ROOT="$XDG_STATE_HOME/rbenv"
x-dc "$RBENV_ROOT"
have gem && path_append "$(gem environment gemdir)/bin"
have rbenv && eval "$(rbenv init - zsh)"
# screen
export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc"
# tmux
export TMUX_CONF="$XDG_CONFIG_HOME/tmux/tmux.conf"
# wakatime, https://github.com/wakatime/wakatime-cli
export WAKATIME_HOME="$XDG_STATE_HOME/wakatime"
@@ -130,9 +127,6 @@ export _Z_DATA="$XDG_STATE_HOME/z"
[[ -f "$XDG_BIN_HOME/z/z.sh" ]] && source "$XDG_BIN_HOME/z/z.sh"
# Misc
export ANDROID_HOME="$XDG_DATA_HOME/android"
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc"
export TMUX_CONF="$XDG_CONFIG_HOME/tmux/tmux.conf"
export BAT_THEME="ansi"
export CHEAT_USE_FZF=true
export SQLITE_HISTORY="$XDG_CACHE_HOME"/sqlite_history

View File

@@ -204,6 +204,19 @@ function have
command -v "$1" >&/dev/null
}
# shorthand for checking if brew package is installed
# usage: have_brew php && php -v
function have_brew
{
! have brew && return 125
if brew list "$1" &> /dev/null; then
return 0
else
return 1
fi
}
# Remove directory from the PATH variable
# usage: path_remove ~/.local/bin
function path_remove