1*4882a593Smuzhiyun# System-wide .bashrc file for interactive bash(1) shells. 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun# To enable the settings / commands in this file for login shells as well, 4*4882a593Smuzhiyun# this file has to be sourced in /etc/profile. 5*4882a593Smuzhiyun 6*4882a593Smuzhiyun# If not running interactively, don't do anything 7*4882a593Smuzhiyun[ -z "$PS1" ] && return 8*4882a593Smuzhiyun 9*4882a593Smuzhiyun# check the window size after each command and, if necessary, 10*4882a593Smuzhiyun# update the values of LINES and COLUMNS. 11*4882a593Smuzhiyunshopt -s checkwinsize 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun# set variable identifying the chroot you work in (used in the prompt below) 14*4882a593Smuzhiyunif [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then 15*4882a593Smuzhiyun debian_chroot=$(cat /etc/debian_chroot) 16*4882a593Smuzhiyunfi 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun# set a fancy prompt (non-color, overwrite the one in /etc/profile) 19*4882a593Smuzhiyun# but only if not SUDOing and have SUDO_PS1 set; then assume smart user. 20*4882a593Smuzhiyunif ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then 21*4882a593Smuzhiyun PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 22*4882a593Smuzhiyunfi 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default. 25*4882a593Smuzhiyun# If this is an xterm set the title to user@host:dir 26*4882a593Smuzhiyun#case "$TERM" in 27*4882a593Smuzhiyun#xterm*|rxvt*) 28*4882a593Smuzhiyun# PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"' 29*4882a593Smuzhiyun# ;; 30*4882a593Smuzhiyun#*) 31*4882a593Smuzhiyun# ;; 32*4882a593Smuzhiyun#esac 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun# enable bash completion in interactive shells 35*4882a593Smuzhiyun#if ! shopt -oq posix; then 36*4882a593Smuzhiyun# if [ -f /usr/share/bash-completion/bash_completion ]; then 37*4882a593Smuzhiyun# . /usr/share/bash-completion/bash_completion 38*4882a593Smuzhiyun# elif [ -f /etc/bash_completion ]; then 39*4882a593Smuzhiyun# . /etc/bash_completion 40*4882a593Smuzhiyun# fi 41*4882a593Smuzhiyun#fi 42*4882a593Smuzhiyun 43*4882a593Smuzhiyun# sudo hint 44*4882a593Smuzhiyunif [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then 45*4882a593Smuzhiyun case " $(groups) " in *\ admin\ *|*\ sudo\ *) 46*4882a593Smuzhiyun if [ -x /usr/bin/sudo ]; then 47*4882a593Smuzhiyun cat <<-EOF 48*4882a593Smuzhiyun To run a command as administrator (user "root"), use "sudo <command>". 49*4882a593Smuzhiyun See "man sudo_root" for details. 50*4882a593Smuzhiyun 51*4882a593Smuzhiyun EOF 52*4882a593Smuzhiyun fi 53*4882a593Smuzhiyun esac 54*4882a593Smuzhiyunfi 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun# if the command-not-found package is installed, use it 57*4882a593Smuzhiyunif [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then 58*4882a593Smuzhiyun function command_not_found_handle { 59*4882a593Smuzhiyun # check because c-n-f could've been removed in the meantime 60*4882a593Smuzhiyun if [ -x /usr/lib/command-not-found ]; then 61*4882a593Smuzhiyun /usr/lib/command-not-found -- "$1" 62*4882a593Smuzhiyun return $? 63*4882a593Smuzhiyun elif [ -x /usr/share/command-not-found/command-not-found ]; then 64*4882a593Smuzhiyun /usr/share/command-not-found/command-not-found -- "$1" 65*4882a593Smuzhiyun return $? 66*4882a593Smuzhiyun else 67*4882a593Smuzhiyun printf "%s: command not found\n" "$1" >&2 68*4882a593Smuzhiyun return 127 69*4882a593Smuzhiyun fi 70*4882a593Smuzhiyun } 71*4882a593Smuzhiyunfi 72