Various deb packaging settings/conveniences
[~bandali/configs] / .bashrc
CommitLineData
ca3a844a
AB
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
2fb49213
AB
24# prompt
25# ------
26
ca3a844a 27b_prompt() {
2fb49213
AB
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 "
ca3a844a 44}
2fb49213 45b_prompt
ca3a844a 46
2fb49213
AB
47# cursor
48# ------
ca3a844a 49
2fb49213
AB
50# i-beam cursor (uncomment one of the two):
51# echo -e "\033[5 q" # blinking
52# echo -e "\033[6 q" # non-blinking
ca3a844a 53
2fb49213
AB
54# general configuration and completions
55# -------------------------------------
ca3a844a 56
810676dd
AB
57# disallow overwriting existing file using redirection
58set -o noclobber
ca3a844a
AB
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
2fb49213 75#HISTIGNORE='ls:l:ll:s:g:[bf]g:history:da:li'
ca3a844a
AB
76HISTTIMEFORMAT='%F %T '
77stty stop ""
78
2fb49213
AB
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
ca3a844a
AB
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'
2fb49213 118alias mpv="mpv --ytdl-format=mp4"
ca3a844a
AB
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"
1f5c92ff 127alias s="startx"
ca3a844a 128
298f42fe
AB
129alias da='change-theme dark'
130alias li='change-theme light'
131
ccbb7191
AB
132alias dquilt="quilt --quiltrc=${XDG_CONFIG_HOME}/quilt/quiltrc-dpkg"
133. /usr/share/bash-completion/completions/quilt
9867e4bb
AB
134complete -F _quilt_completion -o filenames dquilt
135
ca3a844a
AB
136function t {
137 cd $(mktemp -d /tmp/$1.XXXX)
138}