-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
225 lines (184 loc) · 6.16 KB
/
.zshrc
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
ZSH=$HOME/.oh-my-zsh
ZSH_CONFIG=$HOME/.oh-my-zsh-config
DISABLE_AUTO_UPDATE="true"
HIST_STAMPS="dd.mm.yyyy"
plugins=(gitfast pep8 common-aliases dirhistory django docker httpie last-working-dir perms pip pyenv python screen systemd virtualenvwrapper)
ZSH_CACHE_DIR=$HOME/.oh-my-zsh-cache
if [[ ! -d $ZSH_CACHE_DIR ]]; then
mkdir $ZSH_CACHE_DIR
fi
source $ZSH/oh-my-zsh.sh
source $ZSH_CONFIG/themes/zsh-theme-powerlevel9k/powerlevel9k.zsh-theme
#POWERLEVEL9K_MODE="awesome-patched"
POWERLEVEL9K_MODE="awesome-fontconfig"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(ssh context dir virtualenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time status_joined time)
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
#POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND=075
POWERLEVEL9K_VIRTUALENV_BACKGROUND=077
#POWERLEVEL9K_TIME_BACKGROUND=black
#xPOWERLEVEL9K_TIME_FOREGROUND=grey
POWERLEVEL9K_COMMAND_EXECUTION_TIME_PRECISION=2
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND=black
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND=green
#POWERLEVEL9K_VCS_GIT_BITBUCKET_ICON="\uE266" #
#POWERLEVEL9K_EXECUTION_TIME_ICON="\U0231B"
POWERLEVEL9K_STATUS_VERBOSE=false
POWERLEVEL9K_SHORTEN_STRATEGY="truncate_middle"
POWERLEVEL9K_SHORTEN_DIR_LENGTH=3
POWERLEVEL9K_TIME_FORMAT="%D{%H:%M:%S %d.%m}"
#POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="\n"
#POWERLEVEL9K_MULTILINE_SECOND_PROMPT_PREFIX="$(prompt_context "left" 1)$(left_prompt_end)"
source $ZSH_CONFIG/themes/zsh-theme-powerlevel9k/powerlevel9k.zsh-theme
alias nano='nano -W -m -w'
#Aliases from grml-zsh-config
alias 'dus=du -sckx * | sort -nr'
alias insecssh='ssh -o "StrictHostKeyChecking=no" -o "UserKnownHostsFile=/dev/null"'
# Set SSH to use gpg-agent
unset SSH_AGENT_PID
if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
fi
export PATH=~/.local/bin/:$PATH
unalias gcf
function gcf (){
NUMBER=$1
if [[ -z ${NUMBER} ]]
then
echo "Please enter feature number"
return
fi
BRANCHES=$(git branch --list | grep feature/${NUMBER}_)
DESIRED_INDEX=1
BRANCHES_AMOUNT=$(wc -l <<< "$BRANCHES")
REMOTE_BRANCHES=$(git branch --list -r | grep feature/${NUMBER}_)
REMOTE_BRANCHES_AMOUNT=$(wc -l <<< "$REMOTE_BRANCHES")
if [[ -z ${BRANCHES} ]] && [[ -z ${REMOTE_BRANCHES} ]]
then
echo "No feature-branch available with ${NUMBER}"
return
fi
if [[ -n ${BRANCHES} ]]
then
if ! [[ ${BRANCHES_AMOUNT} -eq 1 ]]
then
echo "Choose desired branch:"
echo "$(grep -n . <<< ${BRANCHES})"
read DESIRED_INDEX
if ! [[ "${DESIRED_INDEX}" =~ ^[0-9]+$ ]]
then
DESIRED_INDEX=1
fi
if [[ ${DESIRED_INDEX} -gt ${BRANCHES_AMOUNT} ]]
then
echo "Wrong input"
return
fi
BRANCH=$(head -n ${DESIRED_INDEX} <<< "${BRANCHES}" | tail -n 1 )
else
BRANCH=${BRANCHES}
fi
BRANCH=$(sed 's/^[ ]*//'<<<${BRANCH})
git checkout ${BRANCH}
fi
if [[ -z ${BRANCHES} ]] && [[ -n ${REMOTE_BRANCHES} ]]
then
if ! [[ ${REMOTE_BRANCHES_AMOUNT} -eq 1 ]]
then
echo "Choose desired remote branch:"
echo "$(grep -n . <<< ${REMOTE_BRANCHES})"
read DESIRED_INDEX
if ! [[ "${DESIRED_INDEX}" =~ ^[0-9]+$ ]]
then
DESIRED_INDEX=1
fi
if [[ ${DESIRED_INDEX} -gt ${REMOTE_BRANCHES_AMOUNT} ]]
then
echo "Wrong input"
return
fi
REMOTE_BRANCH=$(head -n ${DESIRED_INDEX} <<< "${REMOTE_BRANCHES}" | tail -n 1 )
else
REMOTE_BRANCH=${REMOTE_BRANCHES}
fi
REMOTE_BRANCH_NAME=$(sed 's/^[ ]*//'<<<${REMOTE_BRANCH})
BRANCH_NAME=$(echo ${REMOTE_BRANCH_NAME} | cut -d '/' -f 2-)
git checkout -b ${BRANCH_NAME} ${REMOTE_BRANCH_NAME}
fi
}
function islinux () {
[[ $GRML_OSTYPE == "Linux" ]]
}
function isfreebsd () {
[[ $GRML_OSTYPE == "FreeBSD" ]]
}
function bk () {
emulate -L zsh
local current_date=$(date -u "+%Y-%m-%dT%H:%M:%SZ")
local clean keep move verbose result all to_bk
setopt extended_glob
keep=1
while getopts ":hacmrv" opt; do
case $opt in
a) (( all++ ));;
c) unset move clean && (( ++keep ));;
m) unset keep clean && (( ++move ));;
r) unset move keep && (( ++clean ));;
v) verbose="-v";;
h) <<__EOF0__
bk [-hcmv] FILE [FILE ...]
bk -r [-av] [FILE [FILE ...]]
Backup a file or folder in place and append the timestamp
Remove backups of a file or folder, or all backups in the current directory
Usage:
-h Display this help text
-c Keep the file/folder as is, create a copy backup using cp(1) (default)
-m Move the file/folder, using mv(1)
-r Remove backups of the specified file or directory, using rm(1). If none
is provided, remove all backups in the current directory.
-a Remove all (even hidden) backups.
-v Verbose
The -c, -r and -m options are mutually exclusive. If specified at the same time,
the last one is used.
The return code is the sum of all cp/mv/rm return codes.
__EOF0__
return 0;;
\?) bk -h >&2; return 1;;
esac
done
shift "$((OPTIND-1))"
if (( keep > 0 )); then
if islinux || isfreebsd; then
for to_bk in "$@"; do
cp $verbose -a "${to_bk%/}" "${to_bk%/}_$current_date"
(( result += $? ))
done
else
for to_bk in "$@"; do
cp $verbose -pR "${to_bk%/}" "${to_bk%/}_$current_date"
(( result += $? ))
done
fi
elif (( move > 0 )); then
while (( $# > 0 )); do
mv $verbose "${1%/}" "${1%/}_$current_date"
(( result += $? ))
shift
done
elif (( clean > 0 )); then
if (( $# > 0 )); then
for to_bk in "$@"; do
rm $verbose -rf "${to_bk%/}"_[0-9](#c4,)-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3])(:[0-5][0-9])(#c2)Z
(( result += $? ))
done
else
if (( all > 0 )); then
rm $verbose -rf *_[0-9](#c4,)-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3])(:[0-5][0-9])(#c2)Z(D)
else
rm $verbose -rf *_[0-9](#c4,)-(0[0-9]|1[0-2])-([0-2][0-9]|3[0-1])T([0-1][0-9]|2[0-3])(:[0-5][0-9])(#c2)Z
fi
(( result += $? ))
fi
fi
return $result
}