Commit | Line | Data |
---|---|---|
a38abd4c 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. | |
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 | ||
16ff2912 AB |
19 | if [ -n "$IS_GUIX_SYSTEM" ]; then |
20 | # Source the system-wide file. | |
21 | source /etc/bashrc | |
22 | fi | |
d99f86cd | 23 | |
acb525a9 | 24 | # from https://unix.stackexchange.com/a/55935 |
a5c8d5d6 | 25 | b_prompt() { |
acb525a9 AB |
26 | cwd=$(sed -e "s:$HOME:~:" -e "s:\(\.\?[^/]\)[^/]*/:\1/:g" <<<$PWD) |
27 | printf $cwd | |
28 | } | |
a5c8d5d6 AB |
29 | |
30 | if [ $(id -u) == "0" ]; then | |
31 | PS1='`printf "\[\e[1;31m\]\$\[\e[00m\]"` ' | |
a38abd4c | 32 | else |
a5c8d5d6 | 33 | PS1='\$ ' |
a38abd4c | 34 | fi |
7d7a2fc9 | 35 | PS1="\u@\h:\w/`[ -n "$GUIX_ENVIRONMENT" ] && printf \" [env]\"`\n$PS1" |
acb525a9 | 36 | |
178f98e1 | 37 | # set terminal title |
a5c8d5d6 | 38 | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: $(b_prompt)\007"' |
178f98e1 | 39 | |
d99f86cd AB |
40 | # i-beam cursor |
41 | # echo -e "\033[5 q" # blinking | |
489798a4 | 42 | echo -e "\033[6 q" # non-blinking |
d99f86cd | 43 | |
58a81de3 | 44 | # various bash tweaks |
16ff2912 | 45 | # append to the history file, don't overwrite it |
58a81de3 AB |
46 | shopt -s histappend |
47 | shopt -s cmdhist | |
16ff2912 AB |
48 | # check the window size after each command and, if necessary, |
49 | # update the values of LINES and COLUMNS. | |
50 | shopt -s checkwinsize | |
51 | # If set, the pattern "**" used in a pathname expansion context will | |
52 | # match all files and zero or more directories and subdirectories. | |
53 | #shopt -s globstar | |
54 | # for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
58a81de3 AB |
55 | HISTSIZE= |
56 | HISTFILESIZE= | |
16ff2912 AB |
57 | # don't put duplicate lines or lines starting with space in the |
58 | # history. | |
58a81de3 | 59 | HISTCONTROL=ignoreboth |
16ff2912 | 60 | # ignore a few very common commands and don't add them to history |
d99f86cd | 61 | HISTIGNORE='ls:l:s:g:[bf]g:history' |
58a81de3 AB |
62 | HISTTIMEFORMAT='%F %T ' |
63 | stty stop "" | |
6b8582fa | 64 | |
dc9a8087 | 65 | # aliases |
a38abd4c | 66 | alias ls='ls -p --color=auto' |
d99f86cd AB |
67 | alias l='ls -lh' # long format and human-readable sizes |
68 | alias ll='l -A' # long format, all files | |
16ff2912 AB |
69 | alias dir='dir --color=auto' |
70 | alias vdir='vdir --color=auto' | |
a38abd4c | 71 | alias grep='grep --color=auto' |
16ff2912 AB |
72 | alias fgrep='fgrep --color=auto' |
73 | alias egrep='egrep --color=auto' | |
dc9a8087 AB |
74 | alias mpv="mpv --ytdl-format mp4" |
75 | alias mv="mv -iv" | |
76 | alias cp="cp -iv" | |
c036d6d7 | 77 | alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc' |
249a5298 | 78 | alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc' |
ab79953a | 79 | alias m="mbsync csclub; mbsync uwaterloo; mbsync shemshak; mbsync gnub" |
dc9a8087 | 80 | alias best="youtube-dl -f best" |
d355f997 AB |
81 | alias e="$EDITOR" |
82 | alias se="SUDO_EDITOR=\"emacsclient\" sudo -e" | |
dc9a8087 AB |
83 | |
84 | aur() { | |
85 | cd ~/usr/builds | |
d55c009f | 86 | [ -d ${1} ] || git clone https://aur.archlinux.org/${1}.git |
dc9a8087 AB |
87 | cd ${1} |
88 | } | |
89 | ||
9c9bf1a2 AB |
90 | function t { |
91 | cd $(mktemp -d /tmp/$1.XXXX) | |
92 | } | |
93 | ||
16ff2912 AB |
94 | # separate alias definitions file, if exists |
95 | if [ -f ~/.bash_aliases ]; then | |
96 | . ~/.bash_aliases | |
97 | fi | |
98 | ||
99 | # enable programmable completion features (not needed if already | |
100 | # enabled in /etc/bash.bashrc and if /etc/profile sources | |
101 | # /etc/bash.bashrc). | |
102 | if ! shopt -oq posix; then | |
103 | if [ -f /usr/share/bash-completion/bash_completion ]; then | |
104 | . /usr/share/bash-completion/bash_completion | |
105 | elif [ -f /etc/bash_completion ]; then | |
106 | . /etc/bash_completion | |
107 | fi | |
108 | fi | |
760875d0 AB |
109 | |
110 | # source Guix shell config dirs, for vte.sh and bash completions | |
e72d011d | 111 | GUIX_PROFILES=("${HOME}/.guix-profile" |
760875d0 AB |
112 | "${HOME}/.config/guix/current") |
113 | for profile in "${GUIX_PROFILES[@]}"; do | |
114 | for dir in "${profile}/etc/bash_completion.d" "${profile}/etc/profile.d"; do | |
115 | if [ -d "${dir}" ]; then | |
116 | for f in "${dir}"/*; do | |
117 | . $f | |
118 | done | |
119 | fi | |
120 | done | |
121 | done |