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