* .config/getmail/getmailrc: Add 'ssl_ciphers = AES256-SHA' needed with getmail6.
[~bandali/configs] / .bashrc
1 # Bash initialization for interactive non-login shells and
2 # for remote shells (info "(bash) Bash Startup Files").
3
4 # Export 'SHELL' to child processes. Programs such as 'screen'
5 # honor it and otherwise use /bin/sh.
6 export SHELL
7
8 if [[ $- != *i* ]]
9 then
10 # We are being invoked from a non-interactive shell. If this
11 # is an SSH session (as in "ssh host command"), source
12 # /etc/profile so we get PATH and other essential variables.
13 [[ -n "$SSH_CLIENT" ]] && source /etc/profile
14
15 # Don't do anything else.
16 return
17 fi
18
19 if [ -n "$IS_GUIX_SYSTEM" ]; then
20 # Source the system-wide file.
21 source /etc/bashrc
22 fi
23
24 # prompt
25 # ------
26
27 if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
28 debian_chroot=$(cat /etc/debian_chroot)
29 fi
30
31 b_prompt() {
32 case $TERM in
33 xterm*)
34 local TITLEBAR="\[\033]0;${debian_chroot:+($debian_chroot) }\h:\w\007\]"
35 ;;
36 *)
37 local TITLEBAR=''
38 ;;
39 esac
40
41 PS1="${TITLEBAR}\
42 $([ $(id -u) = "0" ] && printf "\[\e[1;31m\]")\
43 : ${debian_chroot:+($debian_chroot) }\
44 \h:\w\
45 $([ -n "$GUIX_ENVIRONMENT" ] && printf " [env]")\
46 ;\
47 $([ $(id -u) = "0" ] && printf "\[\e[00m\]")\
48 "
49 }
50 b_prompt
51
52 # cursor
53 # ------
54
55 # i-beam cursor (uncomment one of the two):
56 # echo -e "\033[5 q" # blinking
57 # echo -e "\033[6 q" # non-blinking
58
59 # general configuration and completions
60 # -------------------------------------
61
62 # disallow overwriting existing file using redirection
63 set -o noclobber
64 # append to the history file, don't overwrite it
65 shopt -s histappend
66 shopt -s cmdhist
67 # check the window size after each command and, if necessary,
68 # update the values of LINES and COLUMNS.
69 shopt -s checkwinsize
70 # If set, the pattern "**" used in a pathname expansion context will
71 # match all files and zero or more directories and subdirectories.
72 #shopt -s globstar
73 # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
74 HISTSIZE=
75 HISTFILESIZE=
76 # don't put duplicate lines or lines starting with space in the
77 # history.
78 HISTCONTROL=ignoreboth
79 # ignore a few very common commands and don't add them to history
80 #HISTIGNORE='ls:l:ll:s:g:[bf]g:history:da:li'
81 HISTTIMEFORMAT='%F %T '
82 stty stop ""
83
84 # make less more friendly for non-text input files, see lesspipe(1)
85 [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
86
87 export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
88
89 # enable programmable completion features (not needed if already
90 # enabled in /etc/bash.bashrc and if /etc/profile sources
91 # /etc/bash.bashrc).
92 if ! shopt -oq posix; then
93 if [ -f /usr/share/bash-completion/bash_completion ]; then
94 . /usr/share/bash-completion/bash_completion
95 elif [ -f /etc/bash_completion ]; then
96 . /etc/bash_completion
97 fi
98 fi
99
100 # source Guix shell config dirs, for vte.sh and bash completions
101 GUIX_PROFILES=("${HOME}/.guix-profile"
102 "${HOME}/.config/guix/current")
103 for profile in "${GUIX_PROFILES[@]}"; do
104 for dir in "${profile}/etc/bash_completion.d" "${profile}/etc/profile.d"; do
105 if [ -d "${dir}" ]; then
106 for f in "${dir}"/*; do
107 . $f
108 done
109 fi
110 done
111 done
112
113 # aliases and functions
114 # ---------------------
115
116 if [ -f ~/.bash_aliases ]; then
117 . ~/.bash_aliases
118 fi
119
120 alias ls='ls --color=auto'
121 alias l='ls -Flh' # long format and human-readable sizes
122 alias ll='l -a' # long format, all files
123 alias dir='dir --color=auto'
124 alias vdir='vdir --color=auto'
125 alias grep='grep --color=auto'
126 alias egrep='grep -E --color=auto'
127 alias fgrep='grep -F --color=auto'
128 alias mpv="mpv --ytdl-format=mp4"
129 alias mv="mv -iv"
130 alias cp="cp -iv"
131 alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc'
132 alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc'
133 alias m="mbsync csclub; mbsync kelar; mbsync shemshak; mbsync gnub; getmail"
134 alias e="$EDITOR"
135 alias se="SUDO_EDITOR=\"emacsclient\" sudo -e"
136
137 alias alert='notify-send --urgency=low \
138 -i "$([ $? = 0 ] && echo terminal || echo error)" \
139 "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
140
141 alias da='change-theme dark'
142 alias li='change-theme light'
143
144 bash_completions_dir=/usr/share/bash-completion/completions/
145
146 alias dquilt="quilt --quiltrc=${XDG_CONFIG_HOME}/quilt/quiltrc-dpkg"
147 quilt_comps="${bash_completions_dir}/quilt"
148 if [ -f "${quilt_comps}" ]; then
149 . "${quilt_comps}"
150 complete -F _quilt_completion -o filenames dquilt
151 fi
152
153 pass_otp_comps="${bash_completions_dir}/pass-otp"
154 if [ -f "${pass_otp_comps}" ]; then
155 . "${pass_otp_comps}"
156 fi
157
158 function t {
159 cd $(mktemp -d /tmp/$1.XXXX)
160 }