Update redshift config
[~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
1fb89b32
AB
27if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
28 debian_chroot=$(cat /etc/debian_chroot)
29fi
30
ca3a844a 31b_prompt() {
2fb49213
AB
32 case $TERM in
33 xterm*)
1fb89b32 34 local TITLEBAR="\[\033]0;${debian_chroot:+($debian_chroot) }\h:\w\007\]"
2fb49213
AB
35 ;;
36 *)
37 local TITLEBAR=''
38 ;;
39 esac
40
41 PS1="${TITLEBAR}\
42$([ $(id -u) = "0" ] && printf "\[\e[1;31m\]")\
1fb89b32
AB
43: ${debian_chroot:+($debian_chroot) }\
44\h:\w\
2fb49213
AB
45$([ -n "$GUIX_ENVIRONMENT" ] && printf " [env]")\
46 ;\
47$([ $(id -u) = "0" ] && printf "\[\e[00m\]")\
48 "
ca3a844a 49}
2fb49213 50b_prompt
ca3a844a 51
2fb49213
AB
52# cursor
53# ------
ca3a844a 54
2fb49213
AB
55# i-beam cursor (uncomment one of the two):
56# echo -e "\033[5 q" # blinking
57# echo -e "\033[6 q" # non-blinking
ca3a844a 58
2fb49213
AB
59# general configuration and completions
60# -------------------------------------
ca3a844a 61
810676dd
AB
62# disallow overwriting existing file using redirection
63set -o noclobber
ca3a844a
AB
64# append to the history file, don't overwrite it
65shopt -s histappend
66shopt -s cmdhist
67# check the window size after each command and, if necessary,
68# update the values of LINES and COLUMNS.
69shopt -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)
74HISTSIZE=
75HISTFILESIZE=
76# don't put duplicate lines or lines starting with space in the
77# history.
78HISTCONTROL=ignoreboth
79# ignore a few very common commands and don't add them to history
2fb49213 80#HISTIGNORE='ls:l:ll:s:g:[bf]g:history:da:li'
ca3a844a
AB
81HISTTIMEFORMAT='%F %T '
82stty stop ""
83
1fb89b32
AB
84# make less more friendly for non-text input files, see lesspipe(1)
85[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
86
87export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
88
2fb49213
AB
89# enable programmable completion features (not needed if already
90# enabled in /etc/bash.bashrc and if /etc/profile sources
91# /etc/bash.bashrc).
92if ! 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
98fi
99
100# source Guix shell config dirs, for vte.sh and bash completions
101GUIX_PROFILES=("${HOME}/.guix-profile"
102 "${HOME}/.config/guix/current")
103for 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
111done
112
113# aliases and functions
114# ---------------------
115
116if [ -f ~/.bash_aliases ]; then
117 . ~/.bash_aliases
118fi
119
1fb89b32
AB
120alias ls='ls --color=auto'
121alias l='ls -Flh' # long format and human-readable sizes
122alias ll='l -a' # long format, all files
ca3a844a
AB
123alias dir='dir --color=auto'
124alias vdir='vdir --color=auto'
125alias grep='grep --color=auto'
1fb89b32
AB
126alias egrep='grep -E --color=auto'
127alias fgrep='grep -F --color=auto'
2fb49213 128alias mpv="mpv --ytdl-format=mp4"
ca3a844a
AB
129alias mv="mv -iv"
130alias cp="cp -iv"
131alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc'
132alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc'
1fb89b32 133alias m="mbsync csclub; mbsync kelar; mbsync shemshak; mbsync gnub; getmail"
ca3a844a
AB
134alias e="$EDITOR"
135alias se="SUDO_EDITOR=\"emacsclient\" sudo -e"
1fb89b32
AB
136
137alias 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$//'\'')"'
ca3a844a 140
298f42fe
AB
141alias da='change-theme dark'
142alias li='change-theme light'
143
55b397e4
AB
144bash_completions_dir=/usr/share/bash-completion/completions/
145
ccbb7191 146alias dquilt="quilt --quiltrc=${XDG_CONFIG_HOME}/quilt/quiltrc-dpkg"
55b397e4
AB
147quilt_comps="${bash_completions_dir}/quilt"
148if [ -f "${quilt_comps}" ]; then
149 . "${quilt_comps}"
150 complete -F _quilt_completion -o filenames dquilt
151fi
152
153pass_otp_comps="${bash_completions_dir}/pass-otp"
154if [ -f "${pass_otp_comps}" ]; then
155 . "${pass_otp_comps}"
156fi
9867e4bb 157
ca3a844a
AB
158function t {
159 cd $(mktemp -d /tmp/$1.XXXX)
160}