From ba15f82302b62df73571eba09cadeb0275e4c5c1 Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 20 Aug 2024 01:24:14 +0300 Subject: [PATCH] chore: tweak bashrc, zshrc, alias and exports --- base/bashrc | 3 --- base/zshrc | 61 +++++++++++++++----------------------------------- config/alias | 10 +++++++++ config/exports | 14 +++++++++++- 4 files changed, 41 insertions(+), 47 deletions(-) diff --git a/base/bashrc b/base/bashrc index 355ef4a..65d0205 100644 --- a/base/bashrc +++ b/base/bashrc @@ -18,9 +18,6 @@ x-have oh-my-posh && { eval "$(oh-my-posh init bash --config "$DOTFILES/config/omp/own.toml")" } -. "$XDG_BIN_HOME/asdf/asdf.sh" -. "$XDG_BIN_HOME/asdf/completions/asdf.bash" - x-have antidot && { eval "$(antidot init)" } diff --git a/base/zshrc b/base/zshrc index 5171968..c51fca4 100755 --- a/base/zshrc +++ b/base/zshrc @@ -5,23 +5,14 @@ # export DEBUG=1 export DOTFILES="$HOME/.dotfiles" -export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$HOME/.local/share/bob/nvim-bin:$HOME/.local/share/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" +LOCAL_SHARE="$HOME/.local/share" +export PATH="$HOME/.local/bin:$DOTFILES/local/bin:$LOCAL_SHARE/bob/nvim-bin:$LOCAL_SHARE/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" export SHARED_SCRIPTS_SOURCED=0 source "$DOTFILES/config/shared.sh" eval "$(oh-my-posh init zsh --config "$DOTFILES/config/omp/own.toml")" -# Load asdf -export ASDF_DIR="$XDG_BIN_HOME/asdf" -if [[ -d $ASDF_DIR ]]; then - [[ -d $ASDF_DIR/bin ]] && x-path-prepend "$ASDF_DIR/bin" - [[ -d $ASDF_DIR/shims ]] && x-path-prepend "$ASDF_DIR/shims" - [[ -d $ASDF_DIR/completions ]] && fpath=("$ASDF_DIR/completions" $fpath) - [[ -d $ASDF_DIR/plugins ]] && fpath=("$ASDF_DIR/plugins" $fpath) - source "$ASDF_DIR/asdf.sh" -fi - # Function to load antigen if available load_antigen() { @@ -38,8 +29,15 @@ load_antigen() export ZSH_TMUX_AUTOQUIT=false export ZSH_TMUX_DEFAULT_SESSION_NAME=main - zstyle :omz:plugins:ssh-agent quiet yes + zstyle :omz:plugins:eza 'dirs-first' yes + zstyle :omz:plugins:eza 'git-status' yes + zstyle :omz:plugins:eza 'icons' yes + + if [[ "$OSTYPE" == darwin* ]]; then + zstyle :omz:plugins:ssh-agent keychain yes + fi zstyle :omz:plugins:ssh-agent lazy yes + zstyle :omz:plugins:ssh-agent quiet yes # z, the zsh version export ZSHZ_DATA="$XDG_STATE_HOME/z" @@ -48,14 +46,15 @@ load_antigen() x-have python && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv # these should be always available + antigen bundle jreese/zsh-titles + antigen bundle gnu-utils + antigen bundle ssh-agent antigen bundle gpg-agent antigen bundle brew antigen bundle tmux antigen bundle colored-man-pages - # antigen bundle ssh-agent - antigen bundle jreese/zsh-titles antigen bundle zsh-users/zsh-completions - + antigen bundle eza # this needs to be the last item antigen bundle zsh-users/zsh-syntax-highlighting @@ -73,17 +72,6 @@ source_fzf_config() fi } -# Function to initialize pyenv if available -initialize_pyenv() -{ - if x-have pyenv; then - [[ -d $PYENV_ROOT/bin ]] && x-path-append "$PYENV_ROOT/bin" - [[ -d $PYENV_ROOT/shims ]] && x-path-append "$PYENV_ROOT/shims" - eval "$(pyenv init -)" - eval "$(pyenv virtualenv-init -)" - fi -} - # Function to set up tmux window name plugin if tmux is active setup_tmux_window_name_plugin() { @@ -100,28 +88,15 @@ setup_tmux_window_name_plugin() fi } -# Function to initialize antidot if available -initialize_antidot() -{ - if x-have antidot; then - eval "$(antidot init)" - fi -} - -initialize_direnv() -{ - source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc" -} - main() { load_antigen source_fzf_config - initialize_pyenv setup_tmux_window_name_plugin - initialize_antidot - initialize_direnv + if x-have antidot; then + eval "$(antidot init)" + fi + source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc" } main "$@" - diff --git a/config/alias b/config/alias index 9c05e2e..5982b9e 100755 --- a/config/alias +++ b/config/alias @@ -112,3 +112,13 @@ if [[ $(uname) == 'Darwin' ]]; then # Using herd for php now, so this is not needed anymore # x-set-php-aliases fi + +X_ALIAS_FILES=( + "$HOME/.config/alias-secret" + "$HOME/.config/alias-$(hostname)" + "$HOME/.config/alias-$(hostname)-secret" +) +for aliasFile in "${X_ALIAS_FILES[@]}"; do + [ -f "$aliasFile" ] && source "$aliasFile" && msg "Sourced $aliasFile" +done +unset X_ALIAS_FILES diff --git a/config/exports b/config/exports index dfb3289..8bb2714 100755 --- a/config/exports +++ b/config/exports @@ -15,6 +15,16 @@ export PATH="$XDG_BIN_HOME:$DOTFILES/local/bin:$XDG_DATA_HOME/bob/nvim-bin:$XDG_DATA_HOME/cargo/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" +# Load asdf +export ASDF_DIR="$XDG_BIN_HOME/asdf" +if [[ -d $ASDF_DIR ]]; then + [[ -d $ASDF_DIR/bin ]] && x-path-prepend "$ASDF_DIR/bin" + [[ -d $ASDF_DIR/shims ]] && x-path-prepend "$ASDF_DIR/shims" + [[ -d $ASDF_DIR/completions ]] && fpath=("$ASDF_DIR/completions" $fpath) + [[ -d $ASDF_DIR/plugins ]] && fpath=("$ASDF_DIR/plugins" $fpath) + source "$ASDF_DIR/asdf.sh" +fi + if ! command -v msg &> /dev/null; then # Function to print messages if VERBOSE is enabled # $1 - message (string) @@ -285,6 +295,8 @@ export GREP_OPTIONS="--color=auto" # update the values of LINES and COLUMNS. hash shopt 2> /dev/null && shopt -s checkwinsize +export SHORT_HOST=$(hostname -s) + # Antigen configuration # https://github.com/zsh-users/antigen/wiki/Configuration msg "Setting up Antigen configuration" @@ -401,6 +413,7 @@ export PYENV_ROOT="$XDG_STATE_HOME/pyenv" export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH" x-have pyenv && { eval "$(pyenv init -)" + eval "$(pyenv virtualenv-init -)" } # Ruby @@ -468,4 +481,3 @@ for exportFile in "${X_EXPORTS_FILES[@]}"; do [ -f "$exportFile" ] && source "$exportFile" && msg "Sourced $exportFile" done unset X_EXPORTS_FILES -