Skip to content

1.1. Customize BASH SHELL

Alexis edited this page Jul 26, 2023 · 11 revisions

.bashrc file:

# Source global definitions
if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# Infinite bash history
HISTSIZE=
HISTFILESIZE=

. /usr/share/doc/git/contrib/completion/git-prompt.sh
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
export PS1_HOSTNAME='\[\e[01;33m\]\h '
else
export PS1_HOSTNAME=
fi
PS1=$PS1_HOSTNAME
PS1+="\[\e[01;32m\]\t "
PS1+="\[\e[00;37m\]\u: "
PS1+="\[\e[01;34m\]\w"
PS1+="\[\033[32m\]\$(GIT_PS1_SHOWUNTRACKEDFILES=1 GIT_PS1_SHOWDIRTYSTATE=1 __git_ps1)\[\033[00m\] "
if [ $(id -u) -eq 0 ]; then
PS1+="\# "
else
PS1+="\$ "
fi
export PS1

/etc/inputrc

# Arraws up and down for command search
"\e[A":history-search-backward
"\e[B":history-search-forward

sudo sed -i 's/^.*history-search-backward$/"\\e[A": history-search-backward/g' /etc/inputrc
sudo sed -i 's/^.*history-search-forward$/"\\e[B": history-search-forward/g' /etc/inputrc

For the color in the command:

Extras:

##########################################################################
# FOR GIT
##########################################################################
. /usr/share/doc/git/contrib/completion/git-prompt.sh
if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
export PS1_HOSTNAME='\[\e[01;33m\]\h '
else
export PS1_HOSTNAME=
fi
PS1=$PS1_HOSTNAME
PS1+="\[\e[01;32m\]\t "
PS1+="\[\e[00;37m\]\u: "
PS1+="\[\e[01;34m\]\w"
PS1+="\[\033[32m\]\$(GIT_PS1_SHOWUNTRACKEDFILES=1 GIT_PS1_SHOWDIRTYSTATE=1 __git_ps1)\[\033[00m\] "
if [ $(id -u) -eq 0 ]; then
PS1+="\# "
else
PS1+="\$ "
fi
export PS1