-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc
180 lines (147 loc) · 4.07 KB
/
.bashrc
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/env bash
############################################################################
#### Aliases
if command -v nvim &>/dev/null; then
alias v="nvim"
elif command -v vim &>/dev/null; then
alias v="vim"
elif command -v vi &>/dev/null; then
alias v="vi"
fi
if command -v emacs &>/dev/null; then
alias e="emacs -nw"
alias ew="emacs"
fi
if command -v tmux &>/dev/null; then
alias t="tmux"
fi
if command -v hub &>/dev/null; then
alias g="hub"
elif command -v git &>/dev/null; then
alias g="git"
fi
if command -v exa &>/dev/null; then
ignore_list=".git|node_modules"
l() {
exa --long --classify --color=always --color-scale --all --ignore-glob="${ignore_list}" --header --git "$@"
}
li() {
l --ignore-glob="${ignore_list}|$1" "${@:2}"
}
lg() {
l --grid "$@"
}
lgi() {
lg --ignore-glob="${ignore_list}|$1" "${@:2}"
}
lt() {
l --tree "$@"
}
lti() {
lt --ignore-glob="${ignore_list}|$1" "${@:2}"
}
ltl() {
lt --level="$@"
}
ltli() {
ltl "$1" --ignore-glob="${ignore_list}|$2" "${@:3}"
}
else
alias l="ls -AFGl"
fi
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias .......="cd ../../../../../.."
alias ........="cd ../../../../../../.."
alias .........="cd ../../../../../../../.."
# Shows the last 10 visited directories
alias ds="dirs -v | head -10"
############################################################################
#### Completion
# Cycle through matches for completion
bind "TAB":menu-complete
# Displays a list of the matching files
bind "set show-all-if-ambiguous on"
# First Tab only performs partial completion
bind "set menu-complete-display-prefix on"
# Makes matching case-insensitive
bind "set completion-ignore-case on"
############################################################################
#### Editor
# Allows editting commands in line editor with emacs operations
set -o emacs
# Sets default editor
if command -v nvim &>/dev/null; then
export EDITOR="nvim"
elif command -v vim &>/dev/null; then
export EDITOR="vim"
elif command -v vi &>/dev/null; then
export EDITOR="vi"
fi
export USE_EDITOR=$EDITOR
export VISUAL=$EDITOR
############################################################################
#### Man
# Colored man pages
man() {
env \
LESS_TERMCAP_mb=$(printf "\e[1;32m") \
LESS_TERMCAP_md=$(printf "\e[1;34m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[30;48;5;244m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[4;33m") \
man "$@"
}
############################################################################
#### Miscellaneous
# Doesn’t overwrite existing files with '>' but uses '>!' instead
set -o noclobber
# Enter directory path to automatically cd into the directory
shopt -s autocd
############################################################################
#### Prompt
# Solarized colors
bold=$(tput bold)
base03=$(tput setaf 234)
base02=$(tput setaf 235)
base01=$(tput setaf 240)
base00=$(tput setaf 241)
base0=$(tput setaf 244)
base1=$(tput setaf 245)
base2=$(tput setaf 254)
base3=$(tput setaf 230)
yellow=$(tput setaf 136)
orange=$(tput setaf 166)
red=$(tput setaf 160)
magenta=$(tput setaf 125)
violet=$(tput setaf 61)
blue=$(tput setaf 33)
cyan=$(tput setaf 37)
green=$(tput setaf 64)
reset=$(tput sgr0)
prompt_git_info() {
# Branch info
local ref
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command git rev-parse --short HEAD 2> /dev/null) || \
return 0
# Dirty info
local dirty
if [[ -n $(command git status --porcelain 2> /dev/null | tail -n1) ]]; then
dirty="${red}✗"
else
dirty="${green}✓"
fi
# Remote info
local remote
if $(echo "$(command git log @{upstream}..HEAD 2> /dev/null)" | grep "^commit" &> /dev/null); then
remote="${yellow}+"
fi
echo "(${ref#refs/heads/}) ${dirty}${remote} "
}
export PS1="${bold}${cyan}\u${reset}${bold}@${magenta}\h ${blue}\w ${yellow}\$(prompt_git_info)${reset}${bold}\$ ${reset}"