| 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 | b_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 | } |
| 45 | b_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 |
| 58 | set -o noclobber |
| 59 | # append to the history file, don't overwrite it |
| 60 | shopt -s histappend |
| 61 | shopt -s cmdhist |
| 62 | # check the window size after each command and, if necessary, |
| 63 | # update the values of LINES and COLUMNS. |
| 64 | shopt -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) |
| 69 | HISTSIZE= |
| 70 | HISTFILESIZE= |
| 71 | # don't put duplicate lines or lines starting with space in the |
| 72 | # history. |
| 73 | HISTCONTROL=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' |
| 76 | HISTTIMEFORMAT='%F %T ' |
| 77 | stty 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). |
| 82 | if ! 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 |
| 88 | fi |
| 89 | |
| 90 | # source Guix shell config dirs, for vte.sh and bash completions |
| 91 | GUIX_PROFILES=("${HOME}/.guix-profile" |
| 92 | "${HOME}/.config/guix/current") |
| 93 | for 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 |
| 101 | done |
| 102 | |
| 103 | # aliases and functions |
| 104 | # --------------------- |
| 105 | |
| 106 | if [ -f ~/.bash_aliases ]; then |
| 107 | . ~/.bash_aliases |
| 108 | fi |
| 109 | |
| 110 | alias ls='ls -p --color=auto' |
| 111 | alias l='ls -lh' # long format and human-readable sizes |
| 112 | alias ll='l -A' # long format, all files |
| 113 | alias dir='dir --color=auto' |
| 114 | alias vdir='vdir --color=auto' |
| 115 | alias grep='grep --color=auto' |
| 116 | alias fgrep='fgrep --color=auto' |
| 117 | alias egrep='egrep --color=auto' |
| 118 | alias mpv="mpv --ytdl-format=mp4" |
| 119 | alias mv="mv -iv" |
| 120 | alias cp="cp -iv" |
| 121 | alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc' |
| 122 | alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc' |
| 123 | alias m="mbsync csclub; mbsync uwaterloo; mbsync shemshak; mbsync gnub" |
| 124 | alias best="youtube-dl -f best" |
| 125 | alias e="$EDITOR" |
| 126 | alias se="SUDO_EDITOR=\"emacsclient\" sudo -e" |
| 127 | alias s="startx" |
| 128 | |
| 129 | alias da='change-theme dark' |
| 130 | alias li='change-theme light' |
| 131 | |
| 132 | alias dquilt="quilt --quiltrc=${XDG_CONFIG_HOME}/quilt/quiltrc-dpkg" |
| 133 | . /usr/share/bash-completion/completions/quilt |
| 134 | complete -F _quilt_completion -o filenames dquilt |
| 135 | |
| 136 | function t { |
| 137 | cd $(mktemp -d /tmp/$1.XXXX) |
| 138 | } |