-
Notifications
You must be signed in to change notification settings - Fork 1
/
.shellrc
105 lines (85 loc) · 2.16 KB
/
.shellrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# common startup script for bash & zsh.
# {{{ Ensure private bin dirs are there
mkdir -p $HOME/.bin
mkdir -p $HOME/.local/bin
# }}}
# {{{ Setup PATH
PATH=$HOME/.bin:$HOME/.local/bin:$HOME/go/bin:$HOME/.nimble/bin/:$PATH
BREW="/home/linuxbrew/.linuxbrew/bin/brew"
if [ -x $BREW ]; then
eval "$($BREW shellenv)"
fi
unset BREW
# }}}
## {{{ Aliases
alias ls='ls --color=auto -lh'
alias la='ls --color=auto -lha'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias df='df -h'
alias du='du -h'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# get top 10 shell commands:
alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'
# Alias vi to gvim when running on a display
export EDITOR='vim'
if [ -n "$DISPLAY" -a -n "$(which gvim 2> /dev/null)" ]; then
alias vi='gvim &> /dev/null'
else
alias vi='vim'
fi
# }}}
#{{{ Color definitions
black='\e[0;30m'
blue='\e[0;34m'
green='\e[0;32m'
cyan='\e[0;36m'
red='\e[0;31m'
purple='\e[0;35m'
brown='\e[0;33m'
lightgray='\e[0;37m'
darkgray='\e[1;30m'
lightblue='\e[1;34m'
lightgreen='\e[1;32m'
lightcyan='\e[1;36m'
lightred='\e[1;31m'
lightpurple='\e[1;35m'
yellow='\e[1;33m'
white='\e[1;37m'
nc='\e[0m'
#}}}
# {{{ keychain
#
if [ -x /usr/bin/keychain ]; then
/usr/bin/keychain -q --nogui && source $HOME/.keychain/$HOSTNAME-sh
fi
# }}}
# {{{ some install functions
function install_brew {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
}
function install_yadm {
curl -fLo $HOME/.bin/yadm https://github.com/TheLocehiliosan/yadm/raw/master/yadm && chmod a+x $HOME/.bin/yadm
}
function install_asdf {
git --version &> /dev/null
if [ $? -eq 0 -a ! -d ~/.asdf ]; then
echo "Installing asdf..."
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.11.3
fi
}
# }}}
# {{{ Some helpers
function ask_yes {
read -p "$1 [Yn] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]?$ ]]; then
return 0
else
return 1
fi
}
# }}}