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