[FIX][SHELL] Modify PATH at login only

It's cleaner to only export my modified PATH when I'm logging in,
instead of doing it at each shell launch.

Because Zsh and Bash don't use the same mechanism to let you know you
are in a login session, you gotta check both separately. But that
doesn't matter because lightdm doesn't launch `sh` as a login shell
anyway... So the condition is super messy.
This commit is contained in:
Bruno BELANYI 2019-10-10 16:29:22 +02:00
parent 02ad16c4e8
commit fde97e5b66
2 changed files with 42 additions and 36 deletions

View file

@ -55,9 +55,6 @@ source ~/.profile
# Import my prompt # Import my prompt
source ~/.bash_prompt source ~/.bash_prompt
# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$PATH"
# Export our directory to Termite for opening new terminals # Export our directory to Termite for opening new terminals
if [[ $TERM == xterm-termite ]]; then if [[ $TERM == xterm-termite ]]; then
. /etc/profile.d/vte.sh . /etc/profile.d/vte.sh

View file

@ -1,42 +1,51 @@
# Add our scripts to the path # Export variables during login only, for Bash and Zsh
export PATH="$HOME/.scripts:$PATH" if { [ -n "$BASH_VERSION" ] && shopt -q login_shell; } ||
{ [ -n "$ZSH_VERSION" ] && [[ -o login ]]; } ||
# FIXME: I don't know why lightdm doesn't run sh as a login shell
[ "$0" = /etc/lightdm/Xsession ]; then
# Add our scripts to the path
export PATH="$HOME/.scripts:$PATH"
# Export our favorite editor # Rust installation
export EDITOR=vim export PATH="$HOME/.cargo/bin:$PATH"
export VISUAL=$EDITOR # Also use it when asking for a GUI
# Export our terminal for i3-sensible-terminal
export TERMINAL=termite
# Use my own ranger config file with all mappings defined # User-local bin directories
export RANGER_LOAD_DEFAULT_RC=FALSE export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
# Color ls output depending on filetype with dircolors # Color ls output depending on filetype with dircolors
[ -e "/etc/DIR_COLORS" ] && DIR_COLORS="/etc/DIR_COLORS" [ -e "/etc/DIR_COLORS" ] && DIR_COLORS="/etc/DIR_COLORS"
[ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors" [ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors"
[ -e "$DIR_COLORS" ] || DIR_COLORS="" [ -e "$DIR_COLORS" ] || DIR_COLORS=""
eval "$(dircolors -b $DIR_COLORS)" eval "$(dircolors -b $DIR_COLORS)"
# Use less as my default pager # Use lesspipe as a file preprocessor (unlike bat, can somewhat read pdf)
export PAGER=less { [ -x /usr/bin/lesspipe.sh ] && eval "$(lesspipe.sh)"; } ||
# Allow for colorful man pages, clear the screen on exit { [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"; } # Quoting seems necessary
export LESS='-R -+X'
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
# Use lesspipe as a file preprocessor (unlike bat, can somewhat read pdf) # Export our favorite editor
{ [ -x /usr/bin/lesspipe.sh ] && eval "$(lesspipe.sh)"; } || export EDITOR=vim
{ [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"; } # Quoting seems necessary export VISUAL=$EDITOR # Also use it when asking for a GUI
# Export our terminal for i3-sensible-terminal
export TERMINAL=termite
# Use my preferred pager settings for bat # Use my own ranger config file with all mappings defined
export BAT_PAGER="$PAGER $LESS" export RANGER_LOAD_DEFAULT_RC=FALSE
# Rust installation # Use less as my default pager
export PATH="$HOME/.cargo/bin:$PATH" export PAGER=less
# Allow for colorful man pages, clear the screen on exit
export LESS='-R -+X'
export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline
# Use keychain to handle ssh-agent # Use my preferred pager settings for bat
export BAT_PAGER="$PAGER $LESS"
fi
# Use keychain to handle ssh-agent, in interactive shell too
eval "$(keychain --eval id_rsa --quiet)" eval "$(keychain --eval id_rsa --quiet)"