-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshrc
149 lines (124 loc) · 2.6 KB
/
shrc
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
#!/bin/sh
verbose=no
[ "$verbose" = yes ] && echo Loading shell environment ... >&2
_begin_esc()
{
[ -n "$BASH_VERSION" ] && printf '\x01' && return
[ -n "$ZSH_VERSION" ] && printf '%%{' && return
}
_end_esc()
{
[ -n "$BASH_VERSION" ] && printf '\x02' && return
[ -n "$ZSH_VERSION" ] && printf '%%}' && return
}
_tput_color()
{
_begin_esc
tput setaf "$1"
_end_esc
}
_tput_reset()
{
_begin_esc
tput sgr0
_end_esc
}
_color_palette()
{
if uname | grep -q Darwin
then
YELLOW=148
GREEN=2
PINK=170
else
YELLOW=226
GREEN=46
PINK=199
fi
}
_active_prompt()
{
_color_palette
# Git branch
git_branch=$(git branch 2> /dev/null | sed -n 's/^\* *//p')
if [ -n "$git_branch" ]
then
_tput_color "$YELLOW"
printf '[%s] ' "$git_branch"
fi
unset git_branch
# Current directory
if [ "$PWD" != "$HOME" ]
then
if printf '%s' "$PWD" | grep -q "^$HOME"
then
neat_path="~${PWD#$HOME}"
else
neat_path=$PWD
fi
_tput_color "$GREEN"
printf '%s' "$neat_path"
unset neat_path
fi
# Dollar sign
_tput_color "$PINK"
printf '$ '
_tput_reset
}
PS1='$(_active_prompt)'
gitme()
{
git config user.name "Sunaina Pai"
git config user.email "[email protected]"
git config user.name
git config user.email
}
uncap()
{
setxkbmap -option caps:escape
}
red()
{
case $1 in
off)
pkill redshift
;;
[0-9]*)
pkill redshift
pkill redshift
redshift -v -l 0:0 -t $1:$1 > ~/redshift.log 2>&1 &
;;
"")
pkill redshift
pkill redshift
redshift -v -l 13:77 -t 5000:3700 > ~/redshift.log 2>&1 &
;;
*)
echo 'Usage: red [off | <temperature>]' >&2
;;
esac
}
makemp3()
{
time for f in "$@"
do
ffmpeg -y -i "$f" -q:a 0 "${f%.*}.mp3"
done
}
alias vi='gvim'
if [ -n "$BASH_VERSION" ]
then
[ "$verbose" = yes ] && echo Loading Bash environment ... >&2
# Enable completions.
[ -r "/usr/local/etc/profile.d/bash_completion.sh" ] &&
. "/usr/local/etc/profile.d/bash_completion.sh"
elif [ -n "ZSH_VERSION" ]
then
[ "$verbose" = yes ] && echo Loading ZSH environment ... >&2
# Allow command substitution in prompt (disabled by default)
setopt prompt_subst
# Enable completions.
autoload bashcompinit && bashcompinit
autoload compinit && compinit
fi
[ "$verbose" = yes ] && echo Done >&2