X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=.bashrc;h=8c05ad26d5155c59cb452177b160c0db87364f96;hb=HEAD;hp=12b8016d1e6b3db66054ba5d33afdc83920a5135;hpb=4c123593e75e97248c2f56e0f28e1c0f15dcae06;p=dotfiles.git diff --git a/.bashrc b/.bashrc index 12b8016..a403c77 100644 --- a/.bashrc +++ b/.bashrc @@ -9,7 +9,11 @@ # Copied from .profile to do minor initialization for non-interactive non-login-shells umask 077 -PATH="$HOME"/bin:"$HOME"/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +# Fix default PATH +if [ "$PATH" = "/usr/local/bin:/usr/bin:/bin:/usr/games" ]; then + PATH="$HOME"/bin:"$HOME"/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +fi + if [ -n "$DISPLAY" ]; then PATH=$PATH:/usr/games fi @@ -28,17 +32,23 @@ esac . "$HOME"/.shellrc +# This is the default value set by interactive bash +# when the global value was unset. Unset it here too. if [ "$HISTFILE" = "$HOME/.bash_history" ]; then history -r - # This is the default value set by interactive bash - # when the global value was unset. Unset it here too. unset HISTFILE +else + alias uh="unset HISTFILE; unalias uh" fi # check the window size after each command and, if necessary, # update the values of LINES and COLUMNS. shopt -s checkwinsize +# extended pattern matching, used in $HISTIGNORE +shopt -s extglob +HISTIGNORE='&: *:?*( ):??*( ):clear*( ):exit*( ):logout*( ):llp*( )' + # If set, the pattern "**" used in a pathname expansion context will # match all files and zero or more directories and subdirectories. #shopt -s globstar @@ -49,9 +59,7 @@ shopt -s histappend [ "`type -t ls`" = alias ] && unalias ls [ "`type -t ll`" = alias ] && unalias ll -back() { cd - "$@"; } -functions() { typeset -f "$@"; } -j() { jobs; } +alias functions='typeset -f' if [ -r "$HOME"/admin/prog/bash_prompt ]; then . "$HOME"/admin/prog/bash_prompt @@ -143,8 +151,8 @@ DELEGATE_NOSPACE=1 delegate_completion rsync r rsync_cgmn rsync_cgmn_recode rsyn delegate_completion ssh s delegate_completion wget wget-m wget-wrapper ww -if [ -d "$HOME"/.bash_completion.d -a \ - -n "`ls -A $HOME/.bash_completion.d`" ]; then +if [ -d "$HOME"/.bash_completion.d ] && + [ -n "`ls -A $HOME/.bash_completion.d`" ]; then for _compf in "$HOME"/.bash_completion.d/*; do . $_compf done @@ -153,15 +161,25 @@ fi unset _BASH_COMPLETIONS_DIR has_completion delegate_completion if [ -d "$HOME/lib/config" ]; then - complete -W "`cd \"$HOME/lib/config\" && echo *`" include + complete \ + -W "`cd \"$HOME/lib/config\" && find . -type f -printf '%P\n'`" \ + include fi complete -W "`echo $BROWSER | sed 's/:/ /g'`" start-browser -if [ "`type -t short_curdir`" != function -a \ - -r "$HOME"/admin/prog/bash_prompt ]; then - . "$HOME"/admin/prog/bash_prompt + +if [ -n "$VIRTUAL_ENV" ] && ! type deactivate >/dev/null 2>&1; then + . "$VIRTUAL_ENV/bin/activate" fi +# Clean up python virtual environment on exit +# See https://virtualenvwrapper.readthedocs.io/en/latest/tips.html#clean-up-environments-on-exit + +trap '[ "$VIRTUAL_ENV" ] && deactivate' EXIT + +. virtualenvwrapper_lazy.sh 2>/dev/null + + if test -d "$HOME"/.pyenv then PYENV_ROOT="$HOME"/.pyenv @@ -175,38 +193,33 @@ then fi -. virtualenvwrapper_lazy.sh 2>/dev/null - -if [ -n "$VIRTUAL_ENV" ] && ! type deactivate >/dev/null 2>&1; then - . "$VIRTUAL_ENV/bin/activate" +if test -x /usr/bin/screen >/dev/null 2>&1; then + alias screen_newwin='history -a; screen' fi -# Clean up python virtual environment on exit -# See https://virtualenvwrapper.readthedocs.io/en/latest/tips.html#clean-up-environments-on-exit - -trap '[ "$VIRTUAL_ENV" ] && deactivate' EXIT +if [ "$SHLVL" -eq 1 ] && which startx >/dev/null 2>&1; then + case "`type -t X`" in + alias) + alias _non_bash_X="`alias X | sed -e \"s/^alias X='//\" -e \"s/'\$//\"`" + alias X='history -a; _non_bash_X; history -r' + ;; -if [ "$SHLVL" -eq 1 -a "`type -t X`" = function ] && which startx >/dev/null 2>&1; then - # From https://stackoverflow.com/a/18839557 + function) + # From https://stackoverflow.com/a/18839557 - copy_function() { - test -n "$(declare -f "$1")" || return - eval "${_/$1/$2}" - } + copy_function() { + test -n "$(declare -f "$1")" || return + eval "${_/$1/$2}" + } - rename_function() { - copy_function "$@" || return - unset -f "$1" - } + rename_function() { + copy_function "$@" || return + unset -f "$1" + } - rename_function X _non_bash_X + #rename_function X _non_bash_X - X() { history -a; _non_bash_X; history -r; } -fi - -if test -x /usr/bin/screen >/dev/null 2>&1; then - screen_newwin() { - history -a - screen "$@" - } + #X() { history -a; _non_bash_X; history -r; } + ;; + esac fi