Last active
November 2, 2017 20:13
-
-
Save pgagnidze/b200498f0ea84697c97338ba1758224c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# /etc/bash.bashrc | |
# | |
# If not running interactively, don't do anything | |
[[ $- != *i* ]] && return | |
# Change the window title of X terminals | |
case ${TERM} in | |
[aEkx]term*|rxvt*|gnome*|konsole*|interix) | |
PS1='\[\033]0;\u@\h:\w\007\]' | |
;; | |
screen*) | |
PS1='\[\033k\u@\h:\w\033\\\]' | |
;; | |
*) | |
unset PS1 | |
;; | |
esac | |
# Set colorful PS1 only on colorful terminals, | |
# try to use the external file first to take | |
# advantage of user additions | |
use_color=false | |
if type -P dircolors >/dev/null ; then | |
# Enable colors for ls, etc. Prefer ~/.dircolors | |
LS_COLORS= | |
if [[ -f ~/.dircolors ]] ; then | |
eval "$(dircolors -b ~/.dircolors)" | |
elif [[ -f /etc/DIRCOLORS ]] ; then | |
eval "$(dircolors -b /etc/DIRCOLORS)" | |
else | |
eval "$(dircolors -b)" | |
fi | |
# Evaluate the LS_COLORS setting even when it's the default | |
if [[ -n ${LS_COLORS:+set} ]] ; then | |
use_color=true | |
else | |
# Delete it if it's empty as it's useless in that case | |
unset LS_COLORS | |
fi | |
else | |
# Some systems (e.g. BSD & embedded) don't typically come with | |
# dircolors so we need to hardcode some terminals in here | |
case ${TERM} in | |
[aEkx]term*|rxvt*|gnome*|konsole*|screen|cons25|*color) use_color=true;; | |
esac | |
fi | |
if ${use_color} ; then | |
if [[ ${EUID} == 0 ]] ; then | |
PS1+='\[\033[01;31m\]\W \$\[\033[00m\] ' | |
else | |
PS1+='\[\033[01;34m\]\w \$\[\033[00m\] ' | |
fi | |
alias ls='ls --color=auto' | |
alias grep='grep --colour=auto' | |
alias egrep='egrep --colour=auto' | |
alias fgrep='fgrep --colour=auto' | |
else | |
if [[ ${EUID} == 0 ]] ; then | |
# Show root@ when we don't have colors | |
PS1+='\u@\h \W \$ ' | |
else | |
PS1+='\u@\h \w \$ ' | |
fi | |
fi | |
# if the command-not-found package is installed, use it | |
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then | |
function command_not_found_handle { | |
# check because c-n-f could've been removed in the meantime | |
if [ -x /usr/lib/command-not-found ]; then | |
/usr/lib/command-not-found -- "$1" | |
return $? | |
elif [ -x /usr/share/command-not-found/command-not-found ]; then | |
/usr/share/command-not-found/command-not-found -- "$1" | |
return $? | |
else | |
printf "%s: command not found\n" "$1" >&2 | |
return 127 | |
fi | |
} | |
fi | |
# Add more specialized tab completions for common commands and their options | |
[ -r /usr/share/bash-completion/bash_completion ] && . /usr/share/bash-completion/bash_completion | |
# Try to keep environment pollution down | |
unset use_color sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment