User Tools

Site Tools


bashrc

If you want to send us your comments, please do so. Thanks
More on comments


bashrc

Set terminal to 256 color if it is an xterm

Source Colour everywhere! 256 colour-mode for Linux consoles
Add to .bashrc

case "$TERM" in
  xterm-color) color_prompt=yes;;
  screen)      export TERM=screen-256color;;
  xterm)       export TERM=xterm-256color;;
esac

Color prompt

Add to .bashrc

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color) color_prompt=yes;;
esac
 
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes
 
if [ -n "$force_color_prompt" ]; then
  if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
    # We have color support; assume it's compliant with Ecma-48
    # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
    # a case would tend to support setf rather than setaf.)
    color_prompt=yes
  else
    color_prompt=
  fi
fi
 
#echo $color_prompt
if [ "$color_prompt" = yes ]; then
  # root
  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \#\[\033[00m\]\$ '
  # user
  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \#\[\033[00m\]\$ '
else
  PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

History

HISTCONTROL=$HISTCONTROL${HISTCONTROL+:}=ignoredups:ignorespace:erasedups
HISTSIZE=1000000
HISTFILESIZE=20000000
HISTIGNORE=ls:ls\ -l:
export PROMPT_COMMAND='history -a; history -r'
# append to the history file, don't overwrite it
shopt -s histappend

Preserve history of all termials

Add

export PROMPT_COMMAND='history -a; history -r'

to the .bashrc of all users (and root) who need it
-a Append the new history lines to the history file. These are history lines entered since the beginning of the current Bash session, but not already appended to the history file
-r Read the history file and append its contents to the history list

Differences other configuration files

NameUseRemark
/home/user/.bash_profileOnly for loading .profile first and then .bashrc
/home/user/.profileNon bash related items like environment variables as PATH and items for graphical applications. Items only available to login shells
/home/user/.bashrcSettings for the command line. Prompt, aliases and so on

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
bashrc.txt · Last modified: 09-01-2022 10:52 by wim