Rework final init and SSH session fix

This commit is contained in:
2025-04-24 02:03:55 -03:00
parent b314a6506d
commit 0d03127d06
3 changed files with 44 additions and 36 deletions

View File

@ -142,3 +142,35 @@ alias yarn='yarn --use-yarnrc "$XDG_CONFIG_HOME"/yarn/config'
alias units='units --history "$XDG_DATA_HOME"/units_history'
alias nvidia-settings='nvidia-settings --config="$XDG_CONFIG_HOME"/nvidia/settings'
alias adb='HOME="$XDG_DATA_HOME"/android adb'
# If we have local rust installed, set it up
if [[ -f $XDG_DATA_HOME/cargo/env ]]; then
. "$XDG_DATA_HOME/cargo/env"
fi
# Final shell specific init
if [[ -n $BASH_VERSION ]]; then
# https://github.com/pkasemir/find-the-command
[[ -f /usr/share/doc/find-the-command/ftc.bash ]] && source /usr/share/doc/find-the-command/ftc.bash noupdate quiet info
# https://wiki.archlinux.org/title/Pkgfile#Command_not_found
# [[ -f /usr/share/doc/pkgfile/command-not-found.bash ]] && source /usr/share/doc/pkgfile/command-not-found.bash
# Starship after defining custom prompt, easy to remove
eval "$(starship init bash)"
# Zoxide init has to be last
eval "$(zoxide init bash)"
elif [[ -n $ZSH_VERSION ]]; then
# https://github.com/pkasemir/find-the-command
[[ -f /usr/share/doc/find-the-command/ftc.zsh ]] && source /usr/share/doc/find-the-command/ftc.zsh noupdate quiet info
# https://wiki.archlinux.org/title/Pkgfile#Command_not_found
# [[ -f /usr/share/doc/pkgfile/command-not-found.zsh ]] && source /usr/share/doc/pkgfile/command-not-found.zsh
# Starship after defining custom prompt, easy to remove
hash starship 2>/dev/null && eval "$(starship init zsh)"
# Zoxide init has to be last
hash zoxide 2>/dev/null && eval "$(zoxide init zsh)"
fi

View File

@ -4,17 +4,12 @@
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
source "$XDG_CONFIG_HOME/bash/.bash_aliases"
# Workaround for SSH/Login sessions
# https://github.com/systemd/systemd/issues/7641#issuecomment-680694017
[[ -f /usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator ]] && export "$(/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)"
# If we have local bash-completion, use it
if [[ -f $HOME/.local/bin/bash_completion ]]; then
. "$HOME/.local/bin/bash_completion"
fi
# If we have local rust installed, set it up
if [[ -f $HOME/.local/share/cargo/env ]]; then
. "$HOME/.local/share/cargo/env"
fi
[[ -f $HOME/.local/bin/bash_completion ]] && . "$HOME/.local/bin/bash_completion"
# Bash XDG history
export HISTFILE="$XDG_STATE_HOME"/bash/history
@ -23,8 +18,4 @@ export HISTFILE="$XDG_STATE_HOME"/bash/history
# On github: https://github.com/Scriptim/bash-prompt-generator
PS1='[\u@\h \w]\$ '
# Starship after defining custom prompt, easy to remove
eval "$(starship init bash)"
# Zoxide init has to be last
eval "$(zoxide init bash)"
[[ -f $XDG_CONFIG_HOME/bash/.bash_aliases ]] && source "$XDG_CONFIG_HOME/bash/.bash_aliases"

View File

@ -4,29 +4,18 @@
# If not running interactively, don't do anything
[[ $- != *i* ]] && return
[[ -f $XDG_CONFIG_HOME/bash/.bash_aliases ]] && source "$XDG_CONFIG_HOME/bash/.bash_aliases"
# Workaround for SSH/Login sessions
# https://github.com/systemd/systemd/issues/7641#issuecomment-680694017
[[ -f /usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator ]] && export "$(/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator)"
autoload -Uz promptinit
autoload -Uz compinit
promptinit
compinit -d "$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION"
promptinit
# Some zsh plugins
[[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] && \
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[[ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]] && \
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# find-the-command
# https://github.com/pkasemir/find-the-command
[[ -f /usr/share/doc/find-the-command/ftc.zsh ]] && \
source /usr/share/doc/find-the-command/ftc.zsh noupdate quiet info
# Alternative (pkgfile)
# https://wiki.archlinux.org/title/Pkgfile#Command_not_found
# [[ -f /usr/share/doc/pkgfile/command-not-found.zsh ]] && \
# source /usr/share/doc/pkgfile/command-not-found.zsh
[[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] && source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[[ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]] && source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
bindkey '^[[H' beginning-of-line
bindkey '^[[F' end-of-line
@ -40,8 +29,4 @@ export HISTFILE="$XDG_STATE_HOME"/zsh/history
PROMPT="[%n@%m %~]$ "
RPROMPT="%?:%h | %*"
# Starship after defining custom prompt, easy to remove
eval "$(starship init zsh)"
# Zoxide init has to be last
eval "$(zoxide init zsh)"
[[ -f $XDG_CONFIG_HOME/bash/.bash_aliases ]] && source "$XDG_CONFIG_HOME/bash/.bash_aliases"