* .emacs.d/lisp/bandali-gnus.el: Tweak gnus-posting-styles.
[~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
27if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
28 debian_chroot=$(cat /etc/debian_chroot)
29fi
30
31b_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}
50b_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
63set -o noclobber
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
80#HISTIGNORE='ls:l:ll:s:g:[bf]g:history:da:li'
81HISTTIMEFORMAT='%F %T '
82stty 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
87export 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).
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
120alias ls='ls --color=auto'
121alias l='ls -Flh' # long format and human-readable sizes
122alias ll='l -a' # long format, all files
123alias dir='dir --color=auto'
124alias vdir='vdir --color=auto'
125alias grep='grep --color=auto'
126alias egrep='grep -E --color=auto'
127alias fgrep='grep -F --color=auto'
128alias mpv="mpv --ytdl-format=mp4"
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'
133alias m="mbsync csclub; mbsync kelar; mbsync shemshak; mbsync gnub; getmail"
134alias e="$EDITOR"
135alias se="SUDO_EDITOR=\"emacsclient\" sudo -e"
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$//'\'')"'
140
141alias da='change-theme dark'
142alias li='change-theme light'
143
144bash_completions_dir=/usr/share/bash-completion/completions/
145
146alias dquilt="quilt --quiltrc=${XDG_CONFIG_HOME}/quilt/quiltrc-dpkg"
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
157
158function t {
159 cd $(mktemp -d /tmp/$1.XXXX)
160}