This question is about best practices. I know logging in over secure shell or switching users su, and su -l have different effects. Also, in the event you make a typo in the configuration, you still want to be able to log in. Where is/are the/some ideal place/s to store color definitions? At the moment I have them in .bash_profile. Is it ok to store them in .bashrc?
Configuration Locations:
According to the ArchWiki
/etc/profileSources application settings in/etc/profile.d/*.shand/etc/bash.bashrc.~/.bash_profilePer-user, after/etc/profile.~/.bash_login(if.bash_profilenot found)~/.profile(if.bash_profilenot found)/etc/skel/.bash_profilealso sources~/.bashrc.~/.bash_logout/etc/bash.bashrcDepends on the-DSYS_BASHRC="/etc/bash.bashrc"compilation flag. Sources/usr/share/bash-completion/bash_completion~/.bashrcPer-user, after/etc/bash.bashrc.
Let's save I have two color definitions, one for the command prompt and one for the ls command.
set_prompt () {
Last_Command=$? # Must come first!
Blue='\[\e[01;34m\]'
White='\[\e[01;37m\]'
Redbold='\[\e[01;31m\]'
Greenbold='\[\e[01;32m\]'
Greenlight='\[\e[00;32m\]'
Blueintense='\[\033[00;96m\]'
Purplelight='\[\e[00;35m\]'
Yellowbold='\[\e[01;33m\]'
Graydark='\[\e[01;90m\]'
Reset='\[\e[00m\]'
FancyX='\342\234\227'
Checkmark='\342\234\223'
PS1="${Graydark}\t "
if [[ $Last_Command == 0 ]]; then
PS1+="$Greenlight$Checkmark "
else
PS1+="$Redbold$FancyX "
fi
if [[ $EUID == 0 ]]; then
PS1+="\\u@$Redbold\\h "
else
PS1+="$Greenlight\\u$White@$Redbold\\h "
fi
PS1+="$Graydark\\W $Redbold\\\$$Reset "
}
PROMPT_COMMAND='set_prompt'
set_ls () {
Default='0;0'
White='97'
Yellowbold='01;33'
Greenlight='00;32'
Purplelight='00;35'
Purplebold='01;35'
Whitelight='00;37'
Yellowlight='00;33'
Graydark='00;90'
# Highlight
Highlightpurpledark='45'
Highlightgraydark='100'
LS_COLORS="fi=$Greenlight:di=$White;$Highlightgraydark:*.tex=$Purplebold"
export LS_COLORS
}
set_ls
