bash: start ssh-agent if not running
[~bandali/configs] / .bashrc
CommitLineData
d99f86cd
AB
1# If not running interactively, don't do anything else
2[[ $- != *i* ]] && return
3
4# i-beam cursor
5# echo -e "\033[5 q" # blinking
6echo -e "\033[6 q" # non-blinking
7
58a81de3
AB
8# various bash tweaks
9shopt -s histappend
10shopt -s cmdhist
11HISTSIZE=
12HISTFILESIZE=
13HISTCONTROL=ignoreboth
d99f86cd 14HISTIGNORE='ls:l:s:g:[bf]g:history'
58a81de3
AB
15HISTTIMEFORMAT='%F %T '
16stty stop ""
6b8582fa 17
dc9a8087 18# aliases
6b8582fa 19alias ls='ls --color=auto'
d99f86cd
AB
20alias l='ls -lh' # long format and human-readable sizes
21alias ll='l -A' # long format, all files
22alias g='git'
23include /usr/share/bash-completion/completions/git && __git_complete g _git
dc9a8087
AB
24alias mpv="mpv --ytdl-format mp4"
25alias mv="mv -iv"
26alias cp="cp -iv"
27alias scl=systemctl
28alias jcl=journalctl
29alias m="mbsync csclub; mbsync uwaterloo; mbsync amin"
30alias best="youtube-dl -f best"
31
32aur() {
33 cd ~/usr/builds
34 git clone https://aur.archlinux.org/${1}.git
35 cd ${1}
36}
37
d99f86cd
AB
38# fzf
39include /usr/share/fzf/key-bindings.bash
40include /usr/share/fzf/completion.bash
58a81de3 41
d99f86cd 42# from https://unix.stackexchange.com/a/55935
6e7c85a8 43a_prompt() {
d99f86cd 44 cwd=$(sed -e "s:$HOME:~:" -e "s:\(\.\?[^/]\)[^/]*/:\1/:g" <<<$PWD)
6e7c85a8
AB
45 printf $cwd
46}
47PS1="\u@\h \$(a_prompt)> "
6e39e3a2
AB
48
49if ! pgrep -u "$USER" ssh-agent > /dev/null; then
50 ssh-agent > ~/.ssh-agent-thing
51fi
52if [[ ! "$SSH_AUTH_SOCK" ]]; then
53 eval "$(<~/.ssh-agent-thing)"
54fi