Add Gnus and mbsync configurations for @kelar.org email
[~bandali/configs] / .bashrc
... / ...
CommitLineData
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.
6export SHELL
7
8if [[ $- != *i* ]]
9then
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
17fi
18
19if [ -n "$IS_GUIX_SYSTEM" ]; then
20 # Source the system-wide file.
21 source /etc/bashrc
22fi
23
24# prompt
25# ------
26
27b_prompt() {
28 case $TERM in
29 xterm*)
30 local TITLEBAR='\[\033]0;\h:\w\007\]'
31 ;;
32 *)
33 local TITLEBAR=''
34 ;;
35 esac
36
37 PS1="${TITLEBAR}\
38$([ $(id -u) = "0" ] && printf "\[\e[1;31m\]")\
39: \h:\w\
40$([ -n "$GUIX_ENVIRONMENT" ] && printf " [env]")\
41 ;\
42$([ $(id -u) = "0" ] && printf "\[\e[00m\]")\
43 "
44}
45b_prompt
46
47# cursor
48# ------
49
50# i-beam cursor (uncomment one of the two):
51# echo -e "\033[5 q" # blinking
52# echo -e "\033[6 q" # non-blinking
53
54# general configuration and completions
55# -------------------------------------
56
57# disallow overwriting existing file using redirection
58set -o noclobber
59# append to the history file, don't overwrite it
60shopt -s histappend
61shopt -s cmdhist
62# check the window size after each command and, if necessary,
63# update the values of LINES and COLUMNS.
64shopt -s checkwinsize
65# If set, the pattern "**" used in a pathname expansion context will
66# match all files and zero or more directories and subdirectories.
67#shopt -s globstar
68# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
69HISTSIZE=
70HISTFILESIZE=
71# don't put duplicate lines or lines starting with space in the
72# history.
73HISTCONTROL=ignoreboth
74# ignore a few very common commands and don't add them to history
75#HISTIGNORE='ls:l:ll:s:g:[bf]g:history:da:li'
76HISTTIMEFORMAT='%F %T '
77stty stop ""
78
79# enable programmable completion features (not needed if already
80# enabled in /etc/bash.bashrc and if /etc/profile sources
81# /etc/bash.bashrc).
82if ! shopt -oq posix; then
83 if [ -f /usr/share/bash-completion/bash_completion ]; then
84 . /usr/share/bash-completion/bash_completion
85 elif [ -f /etc/bash_completion ]; then
86 . /etc/bash_completion
87 fi
88fi
89
90# source Guix shell config dirs, for vte.sh and bash completions
91GUIX_PROFILES=("${HOME}/.guix-profile"
92 "${HOME}/.config/guix/current")
93for profile in "${GUIX_PROFILES[@]}"; do
94 for dir in "${profile}/etc/bash_completion.d" "${profile}/etc/profile.d"; do
95 if [ -d "${dir}" ]; then
96 for f in "${dir}"/*; do
97 . $f
98 done
99 fi
100 done
101done
102
103# aliases and functions
104# ---------------------
105
106if [ -f ~/.bash_aliases ]; then
107 . ~/.bash_aliases
108fi
109
110alias ls='ls -p --color=auto'
111alias l='ls -lh' # long format and human-readable sizes
112alias ll='l -A' # long format, all files
113alias dir='dir --color=auto'
114alias vdir='vdir --color=auto'
115alias grep='grep --color=auto'
116alias fgrep='fgrep --color=auto'
117alias egrep='egrep --color=auto'
118alias mpv="mpv --ytdl-format=mp4"
119alias mv="mv -iv"
120alias cp="cp -iv"
121alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc'
122alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc'
123alias m="mbsync csclub; mbsync uwaterloo; mbsync shemshak; mbsync gnub"
124alias best="youtube-dl -f best"
125alias e="$EDITOR"
126alias se="SUDO_EDITOR=\"emacsclient\" sudo -e"
127alias s="startx"
128
129alias da='change-theme dark'
130alias li='change-theme light'
131
132alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg"
133complete -F _quilt_completion -o filenames dquilt
134
135function t {
136 cd $(mktemp -d /tmp/$1.XXXX)
137}