1 # [[file:readme.org::*.bashrc][bashrc]]
4 #HACK as rxvt is sgid utmp and kill TMPDIR
8 # If not running interactively, don't do anything
9 [ -z "$PS1" ] && return
11 # Turn off posix mode if it somehow got turned on.
14 # check the window size after each command and, if necessary,
15 # update the values of LINES and COLUMNS.
18 # Enable the recursive wildcard **
19 shopt -s globstar 2>/dev/null
21 # Append history rather than replacing it
24 # Do not complete an empty command (listing every program in $PATH)
25 shopt -s no_empty_cmd_completion
27 # make less more friendly for non-text input files, see lesspipe(1)
28 [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"
33 # enable color support of ls and also add handy aliases so ls works the same where ever I am.
34 if [ -x /usr/bin/dircolors ]; then
36 LS=$(which ls) # get ls from the path, if it's not in $PATH by this time, there are other issues.
37 # if I'm on a lovely AIX box that has dircolors, I have use gnu ls.
38 [ -x /opt/freeware/bin/ls ] && LS=/opt/freeware/bin/ls
39 alias ls="${LS} --color=auto -v"
40 elif [ -x /usr/local/bin/dircolors ]; then
41 eval "`/usr/local/bin/dircolors -b`"
42 if [ -x /usr/local/bin/gnuls ]; then
43 alias ls='/usr/local/bin/gnuls --color=auto -v'
49 # For use when piping into something like less that can handle color
50 alias cgrep='grep --color=always'
52 # Make Control-v paste, if in X and if xsel available
53 if [ -n "$DISPLAY" ] && [ -x /usr/bin/xsel ] ; then
54 # Work around a bash bug: \C-@ does not work in a key binding
55 bind '"\C-x\C-m": set-mark'
56 # The '#' characters ensure that kill commands have text to work on; if
57 # not, this binding would malfunction at the start or end of a line.
58 bind 'Control-v: "#\C-b\C-k#\C-x\C-?\"$(xsel -b -o)\"\e\C-e\C-x\C-m\C-a\C-y\C-?\C-e\C-y\ey\C-x\C-x\C-d"'
61 # handle bash completion before setting PS1 so we can do cool things
62 # like add git branch to prompt....
64 if [ -z "$BASH_COMPLETION" ] && [ -f /etc/bash_completion ]; then
65 . /etc/bash_completion
68 # cygwin doesn't include git-prompt.sh, so I just include it in .etc
69 if [ -f $HOME/.git-prompt.sh ]; then
70 . $HOME/.git-prompt.sh
71 export GIT_PS1_SHOWDIRTYSTATE="verbose name git"
72 export GIT_PS1_SHOWSTASHSTATE="verbose name git"
73 export GIT_PS1_SHOWUNTRACKEDFILES="verbose name git"
74 export GIT_PS1_SHOWUPSTREAM="verbose name git"
77 # determine if we have git completion
78 if [ -n "$(typeset -F __git_ps1)" ] ; then
79 have_git_completion=true
82 # set variable identifying the chroot you work in (used in the prompt below)
83 if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
84 debian_chroot=$(cat /etc/debian_chroot)
87 # Only show username and hostname if remote or unusual
88 if [ -n "$SSH_CONNECTION" ] || [ "$(id -un)" != "james" ] ; then
92 if [ $GUIX_ENVIRONMENT ]; then
93 PS1='$(e="$?";[ "$e" -ne 0 ] && echo -n "\[\e[01;31m\]($e) ")${debian_chroot:+\[\e[01;37m\]($debian_chroot) }${prompt_remote:+\[\e[01;32m\]\u@\h\[\e[00m\]:}\[\e[01;34m\]\w${have_git_completion:+$(__git_ps1 " (%s)")}\[\e[00m\] [env]\$ '
95 PS1='$(e="$?";[ "$e" -ne 0 ] && echo -n "\[\e[01;31m\]($e) ")${debian_chroot:+\[\e[01;37m\]($debian_chroot) }${prompt_remote:+\[\e[01;32m\]\u@\h\[\e[00m\]:}\[\e[01;34m\]\w${have_git_completion:+$(__git_ps1 " (%s)")}\[\e[00m\] \$ '
98 # Set title as appropriate for terminal
100 "dumb") # fancy prompts confuse tramp.
104 PS1="\[\e]0;${prompt_remote:+\u@\h: }\w\a\]$PS1"
107 PS1="\[\ek${prompt_remote:+\u@\h: }\w\e"'\\'"\]$PS1"
112 # 4) Consider changing your PS1 to also show the current branch:
113 # PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
115 # The argument to __git_ps1 will be displayed only if you
116 # are currently in a git repository. The %s token will be
117 # the name of the current branch.
119 export GPG_TTY=$(tty)