From cdf5c6e541f9b2c321dcecec2d6d74f17ca1d65d Mon Sep 17 00:00:00 2001 From: Uyanide Date: Sun, 26 Jul 2026 20:18:37 +0200 Subject: [PATCH] update shell config --- config/shell/.bash_profile | 10 +++- config/shell/.bashrc | 23 +++++++- config/shell/.config/zsh/conf.d/.gitignore | 1 + .../shell/.config/zsh/conf.d/01-options.zsh | 2 + config/shell/.config/zsh/conf.d/10-done.zsh | 2 +- config/shell/.config/zsh/conf.d/60-direnv.zsh | 3 + config/shell/.zprofile | 55 +----------------- config/shell/.zshenv | 58 +++++++++++++++++++ 8 files changed, 95 insertions(+), 59 deletions(-) create mode 100644 config/shell/.config/zsh/conf.d/60-direnv.zsh create mode 100644 config/shell/.zshenv diff --git a/config/shell/.bash_profile b/config/shell/.bash_profile index cb6d3ea..2138ac7 100644 --- a/config/shell/.bash_profile +++ b/config/shell/.bash_profile @@ -22,9 +22,6 @@ prepend_path() { esac } -# .profile is not included in the repo -[ -f "$HOME/.profile" ] && . "$HOME/.profile" - # Better than nothing export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} @@ -37,8 +34,15 @@ if [[ -z "$LANG" ]]; then export LANG fi +# .profile is not included in the repo +[ -f "$HOME/.profile" ] && . "$HOME/.profile" + # Paths [ -f "$HOME/.cargo/env" ] && source "$HOME/.cargo/env" +if type opam &>/dev/null; then + eval "$(opam env)" +fi +prepend_path "$HOME/.cargo/bin" prepend_path "$HOME/go/bin" prepend_path "$HOME/.local/bin" prepend_path "$HOME/.local/scripts" diff --git a/config/shell/.bashrc b/config/shell/.bashrc index af14745..e673d6f 100644 --- a/config/shell/.bashrc +++ b/config/shell/.bashrc @@ -31,7 +31,7 @@ if ! shopt -oq posix; then fi fi -for app in nvim helix vim vi nano; do +for app in helix nvim vim vi nano; do if type "$app" &>/dev/null; then EDITOR="$app" VISUAL="$app" @@ -69,3 +69,24 @@ fi if type starship &>/dev/null; then eval "$(starship init bash)" fi + +if type fzf &>/dev/null; then + source <(fzf --bash) + + # use fd if available (search cwd only, skip vcs/cache junk) + if type fd &>/dev/null; then + export FD_CMD="fd" + elif type fdfind &>/dev/null; then + export FD_CMD="fdfind" + fi + if [[ -n "$FD_CMD" ]]; then + export FZF_DEFAULT_COMMAND="$FD_CMD --type f --hidden --exclude .git" + export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" + export FZF_ALT_C_COMMAND="$FD_CMD --type d --hidden --exclude .git" + fi + + # C-y to copy fzf's output + if type wl-copy &>/dev/null; then + export FZF_DEFAULT_OPTS="--bind \"ctrl-y:execute-silent(echo -n {+} | wl-copy)+abort\"" + fi +fi diff --git a/config/shell/.config/zsh/conf.d/.gitignore b/config/shell/.config/zsh/conf.d/.gitignore index 91122be..4212465 100644 --- a/config/shell/.config/zsh/conf.d/.gitignore +++ b/config/shell/.config/zsh/conf.d/.gitignore @@ -9,4 +9,5 @@ !10-sshs.zsh !50-prompt.zsh !60-alias.zsh +!60-direnv.zsh !60-fetch.zsh diff --git a/config/shell/.config/zsh/conf.d/01-options.zsh b/config/shell/.config/zsh/conf.d/01-options.zsh index 73af7e4..1943c11 100644 --- a/config/shell/.config/zsh/conf.d/01-options.zsh +++ b/config/shell/.config/zsh/conf.d/01-options.zsh @@ -8,6 +8,8 @@ setopt HIST_IGNORE_DUPS HIST_SAVE_NO_DUPS HIST_FIND_NO_DUPS setopt HIST_IGNORE_SPACE HIST_REDUCE_BLANKS INC_APPEND_HISTORY setopt HIST_VERIFY +mkdir -p "${XDG_DATA_HOME:-$HOME/.local/share}/zsh" + # Shell options setopt AUTO_CD EXTENDED_GLOB NOTIFY INTERACTIVE_COMMENTS diff --git a/config/shell/.config/zsh/conf.d/10-done.zsh b/config/shell/.config/zsh/conf.d/10-done.zsh index 5917523..590ba8c 100644 --- a/config/shell/.config/zsh/conf.d/10-done.zsh +++ b/config/shell/.config/zsh/conf.d/10-done.zsh @@ -59,7 +59,7 @@ uy_done_precmd() { --urgency="$urgency" \ --icon=utilities-terminal \ --app-name=zsh \ - "$title" "$wd/ $uy_done_cmd" & + "$title" "$wd/ $uy_done_cmd" & disown } autoload -Uz add-zsh-hook diff --git a/config/shell/.config/zsh/conf.d/60-direnv.zsh b/config/shell/.config/zsh/conf.d/60-direnv.zsh new file mode 100644 index 0000000..e63280a --- /dev/null +++ b/config/shell/.config/zsh/conf.d/60-direnv.zsh @@ -0,0 +1,3 @@ +if (( $+commands[direnv] )); then + eval "$(direnv hook zsh)" +fi diff --git a/config/shell/.zprofile b/config/shell/.zprofile index 86e1ca1..36ef79f 100644 --- a/config/shell/.zprofile +++ b/config/shell/.zprofile @@ -1,56 +1,6 @@ #!/hint/zsh -# Login shell only — runs once per session (like .bash_profile) - -# Path helpers (needed before sourcing .profile) - -append_path() { - [[ -z "$1" ]] && return - [[ -d "$1" ]] || return - case ":$PATH:" in - *:"$1":*) ;; - *) - PATH="${PATH:+$PATH:}$1" - ;; - esac -} -prepend_path() { - [[ -z "$1" ]] && return - [[ -d "$1" ]] || return - case ":$PATH:" in - *:"$1":*) ;; - *) - PATH="$1${PATH:+:$PATH}" - ;; - esac -} - -# XDG, better than not set - -export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} -export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} -export XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} -export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} - -# Locale, better than not set - -if [[ -z "$LANG" ]]; then - export LANG="en_US.UTF-8" -fi - -# .profile is not included in the repo (private / per-device) -[[ -f "$HOME/.profile" ]] && . "$HOME/.profile" - -# Paths - -[[ -f "$HOME/.cargo/env" ]] && source "$HOME/.cargo/env" -(( $+commands[opam] )) && eval "$(opam env)" -prepend_path "$HOME/.cargo/bin" -prepend_path "$HOME/go/bin" -prepend_path "$HOME/.local/bin" -prepend_path "$HOME/.local/scripts" -prepend_path "$HOME/.local/share/fnm" -export PATH +# Login shell only — runs once per session # GPG agent for SSH @@ -70,6 +20,3 @@ if (( $+commands[ssh-add] )) && (( $+commands[ssh-agent] )) && eval "$($HOME/.local/scripts/ssh-init 2>/dev/null)" &>/dev/null export UY_USING_SSH_AGENT=1 fi - -unfunction append_path -unfunction prepend_path diff --git a/config/shell/.zshenv b/config/shell/.zshenv new file mode 100644 index 0000000..f90f882 --- /dev/null +++ b/config/shell/.zshenv @@ -0,0 +1,58 @@ +#!/hint/zsh + +append_path() { + [[ -z "$1" ]] && return + [[ -d "$1" ]] || return + case ":$PATH:" in + *:"$1":*) ;; + *) + PATH="${PATH:+$PATH:}$1" + ;; + esac +} +prepend_path() { + [[ -z "$1" ]] && return + [[ -d "$1" ]] || return + case ":$PATH:" in + *:"$1":*) ;; + *) + PATH="$1${PATH:+:$PATH}" + ;; + esac +} + +# XDG, better than not set + +export XDG_CONFIG_HOME=${XDG_CONFIG_HOME:-$HOME/.config} +export XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} +export XDG_STATE_HOME=${XDG_STATE_HOME:-$HOME/.local/state} +export XDG_CACHE_HOME=${XDG_CACHE_HOME:-$HOME/.cache} + +# Locale, better than not set + +if [[ -z "$LANG" ]]; then + export LANG="en_US.UTF-8" +fi + +# Somewhat expensive + +if [[ -z "$UY_ENV_DONE" ]]; then + [[ -f "$HOME/.profile" ]] && . "$HOME/.profile" + (( $+commands[opam] )) && eval "$(opam env)" + export UY_ENV_DONE=1 +fi + +# Paths + +[[ -f "$HOME/.cargo/env" ]] && source "$HOME/.cargo/env" +(( $+commands[opam] )) && eval "$(opam env)" +prepend_path "$HOME/.local/share/fnm/aliases/default/bin" # 'fnm env' is eval'ed in .zshrc +prepend_path "$HOME/.cargo/bin" +prepend_path "$HOME/go/bin" +prepend_path "$HOME/.local/bin" +prepend_path "$HOME/.local/scripts" +prepend_path "$HOME/.local/share/fnm" +export PATH + +unfunction append_path +unfunction prepend_path