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 | ||
19 | # Source the system-wide file. | |
20 | source /etc/bashrc | |
d99f86cd | 21 | |
acb525a9 AB |
22 | # from https://unix.stackexchange.com/a/55935 |
23 | a_prompt() { | |
24 | cwd=$(sed -e "s:$HOME:~:" -e "s:\(\.\?[^/]\)[^/]*/:\1/:g" <<<$PWD) | |
25 | printf $cwd | |
26 | } | |
a38abd4c AB |
27 | # Adjust the prompt depending on whether we're in 'guix environment'. |
28 | if [ -n "$GUIX_ENVIRONMENT" ] | |
29 | then | |
30 | PS1="\u@\h [env] \$(a_prompt)> " | |
31 | else | |
32 | PS1="\u@\h \$(a_prompt)> " | |
33 | fi | |
acb525a9 | 34 | |
d99f86cd AB |
35 | # i-beam cursor |
36 | # echo -e "\033[5 q" # blinking | |
9daac239 | 37 | # echo -e "\033[6 q" # non-blinking |
d99f86cd | 38 | |
58a81de3 AB |
39 | # various bash tweaks |
40 | shopt -s histappend | |
41 | shopt -s cmdhist | |
42 | HISTSIZE= | |
43 | HISTFILESIZE= | |
44 | HISTCONTROL=ignoreboth | |
d99f86cd | 45 | HISTIGNORE='ls:l:s:g:[bf]g:history' |
58a81de3 AB |
46 | HISTTIMEFORMAT='%F %T ' |
47 | stty stop "" | |
6b8582fa | 48 | |
dc9a8087 | 49 | # aliases |
a38abd4c | 50 | alias ls='ls -p --color=auto' |
d99f86cd AB |
51 | alias l='ls -lh' # long format and human-readable sizes |
52 | alias ll='l -A' # long format, all files | |
a38abd4c | 53 | alias grep='grep --color=auto' |
dc9a8087 AB |
54 | alias mpv="mpv --ytdl-format mp4" |
55 | alias mv="mv -iv" | |
56 | alias cp="cp -iv" | |
c036d6d7 | 57 | alias mbsync='mbsync -c "$XDG_CONFIG_HOME"/isync/mbsyncrc' |
249a5298 | 58 | alias getmail='getmail --getmaildir "$XDG_CONFIG_HOME"/getmail --rcfile getmailrc' |
d4cc5497 | 59 | alias mb="mbsync csclub; mbsync uwaterloo; mbsync shemshak" |
249a5298 AB |
60 | alias gm="getmail" |
61 | alias m="mb; gm" | |
dc9a8087 | 62 | alias best="youtube-dl -f best" |
d355f997 AB |
63 | alias e="$EDITOR" |
64 | alias se="SUDO_EDITOR=\"emacsclient\" sudo -e" | |
dc9a8087 AB |
65 | |
66 | aur() { | |
67 | cd ~/usr/builds | |
d55c009f | 68 | [ -d ${1} ] || git clone https://aur.archlinux.org/${1}.git |
dc9a8087 AB |
69 | cd ${1} |
70 | } | |
71 | ||
d99f86cd | 72 | # fzf |
9daac239 AB |
73 | #include /usr/share/fzf/key-bindings.bash |
74 | #include /usr/share/fzf/completion.bash | |
58a81de3 | 75 | |
6e39e3a2 AB |
76 | if ! pgrep -u "$USER" ssh-agent > /dev/null; then |
77 | ssh-agent > ~/.ssh-agent-thing | |
78 | fi | |
79 | if [[ ! "$SSH_AUTH_SOCK" ]]; then | |
80 | eval "$(<~/.ssh-agent-thing)" | |
81 | fi |