5 # ~/.bashrc: executed by bash(1) for non-login shells.
6 # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
9 # Copied from .profile to do minor initialization for non-interactive non-login-shells
13 if [ "$PATH" = "/usr/local/bin:/usr/bin:/bin:/usr/games" ]; then
14 PATH="$HOME"/bin:"$HOME"/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
17 if [ -n "$DISPLAY" ]; then
21 # Make `ssh host date` to display in 24-hour format
24 # If not running interactively, don't do anything
30 # Stop if non-interactive shell
31 [ -z "$PS1" ] && return
35 if [ "$HISTFILE" = "$HOME/.bash_history" ]; then
37 # This is the default value set by interactive bash
38 # when the global value was unset. Unset it here too.
42 # check the window size after each command and, if necessary,
43 # update the values of LINES and COLUMNS.
46 # If set, the pattern "**" used in a pathname expansion context will
47 # match all files and zero or more directories and subdirectories.
50 # append to the history file, don't overwrite it
53 [ "`type -t ls`" = alias ] && unalias ls
54 [ "`type -t ll`" = alias ] && unalias ll
57 functions() { typeset -f "$@"; }
60 if [ -r "$HOME"/admin/prog/bash_prompt ]; then
61 . "$HOME"/admin/prog/bash_prompt
65 PS1="${debian_chroot:+($debian_chroot)}\u@\h:\W \$SHLVL\\$ "
68 if [ -z "$BASH_COMPLETION_COMPAT_DIR" ]; then
69 if [ -d /usr/share/bash-completion -a -r /usr/share/bash-completion/bash_completion ]; then
70 _BASH_COMPLETIONS_DIR=/usr/share/bash-completion/completions
71 . /usr/share/bash-completion/bash_completion
72 elif [ -r /etc/bash_completion ]; then
73 _BASH_COMPLETIONS_DIR=/etc/bash_completion.d
74 . /etc/bash_completion
75 elif [ -d /etc/bash_completion.d ] &&
76 [ -n "`ls -A /etc/bash_completion.d`" ]; then
77 _BASH_COMPLETIONS_DIR=/etc/bash_completion.d
78 for _compf in /etc/bash_completion.d/*; do
81 elif [ -d /usr/local/etc/bash_completion.d ] &&
82 [ -n "`ls -A /usr/local/etc/bash_completion.d`" ]; then
83 _BASH_COMPLETIONS_DIR=/usr/local/etc/bash_completion.d
84 for _compf in /usr/local/etc/bash_completion.d/*; do
88 echo "Unknown OS type, cannot source bash_completion" >&2
93 [ -n "$_BASH_COMPLETIONS_DIR" -a -d "$_BASH_COMPLETIONS_DIR" -a -r "$_BASH_COMPLETIONS_DIR/$1" ] ||
94 complete -p $1 >/dev/null 2>&1
97 for cmd in builtin cgmem_nice command dbus-launch exec \
98 killall man nice nohup pidof pidOf KillAll pgrep pkill psg pswg \
99 run-hosts su sudo time whence whereis which xargs; do
100 has_completion $cmd || complete -o default -A command $cmd
103 for cmd in dig host mtr nslookup nc netcat nmap p ping ping6 \
104 ssh2 s2 socat telnet t tt \
105 tcptraceroute tcptraceroute6 tracert tracert6 traceroute traceroute6 \
106 whois wd wget wget-download wget-m wget-wrapper ww; do
107 has_completion $cmd || complete -A hostname $cmd
110 for cmd in distribute ftp lftp r rsync \
111 s scp ssh smbclient tcpdump tshark wireshark; do
112 has_completion $cmd || complete -o default -A hostname $cmd
115 for cmd in bg fg jobs; do
116 has_completion $cmd || complete -A job $cmd
119 complete -A job j wait
122 has_completion $cmd || complete -A function -A variable $cmd
125 delegate_completion() {
128 has_completion $prog || return 0
131 eval "_${prog}_completion_loader() {
132 _completion_loader $prog
133 if [ x"$DELEGATE_NOSPACE" = x1 ]; then
134 complete -o nospace -F _$prog $programs
136 complete -F _$prog $programs
138 unset _${prog}_completion_loader
141 complete -F _${prog}_completion_loader $programs
144 delegate_completion make m
145 delegate_completion ping p
146 DELEGATE_NOSPACE=1 delegate_completion rsync r rsync_cgmn rsync_cgmn_recode rsync_cgmn_recode2
147 delegate_completion ssh s
148 delegate_completion wget wget-m wget-wrapper ww
150 if [ -d "$HOME"/.bash_completion.d ] &&
151 [ -n "`ls -A $HOME/.bash_completion.d`" ]; then
152 for _compf in "$HOME"/.bash_completion.d/*; do
157 unset _BASH_COMPLETIONS_DIR has_completion delegate_completion
159 if [ -d "$HOME/lib/config" ]; then
160 complete -W "`cd \"$HOME/lib/config\" && echo *`" include
162 complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser
165 if [ -n "$VIRTUAL_ENV" ] && ! type deactivate >/dev/null 2>&1; then
166 . "$VIRTUAL_ENV/bin/activate"
168 if test -d "$HOME"/.pyenv
170 PYENV_ROOT="$HOME"/.pyenv
172 PATH="$PYENV_ROOT/bin:$PATH"
173 if which pyenv >/dev/null 2>&1; then
174 # eval "`pyenv init --path`"
175 eval "`pyenv init -`"
176 eval "`pyenv virtualenv-init -`"
181 if [ -n "$VIRTUAL_ENV" ] && ! type deactivate >/dev/null 2>&1; then
182 . "$VIRTUAL_ENV/bin/activate"
185 # Clean up python virtual environment on exit
186 # See https://virtualenvwrapper.readthedocs.io/en/latest/tips.html#clean-up-environments-on-exit
188 trap '[ "$VIRTUAL_ENV" ] && deactivate' EXIT
190 . virtualenvwrapper_lazy.sh 2>/dev/null
193 if test -x /usr/bin/screen >/dev/null 2>&1; then
200 if [ "$SHLVL" -eq 1 -a "`type -t X`" = function ] && which startx >/dev/null 2>&1; then
201 # From https://stackoverflow.com/a/18839557
204 test -n "$(declare -f "$1")" || return
209 copy_function "$@" || return
213 rename_function X _non_bash_X
215 X() { history -a; _non_bash_X; history -r; }