-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.bashrc_yk
204 lines (166 loc) · 5.16 KB
/
.bashrc_yk
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
###########################################################################
####################### START Node ########################################
###########################################################################
export NVM_HOME="$HOME/.nvm"
if [[ -f "$NVM_HOME/nvm.sh" ]]
then
source "$NVM_HOME/nvm.sh"
fi
# tab completion for NVM
if [[ -f "$NVM_HOME/bash_completion" ]]
then
source "$NVM_HOME/bash_completion"
fi
# tab completion for npm
if npm -v > /dev/null 2>&1
then
. <(npm completion)
fi
###########################################################################
####################### END Node ##########################################
###########################################################################
# Change the PS1
export PS1="${debian_chroot:+($debian_chroot)}\u@\h:\W\$ "
# change directory to /bash_scripts
cd /bash_scripts
# python path
export PYTHONPATH="/python/modules/"
# add some stuff to the path
export PATH="$PATH:/bash_scripts:/python"
# for git
## colored output
git config --global color.ui auto
## set default editor to sublime text 3
## git config --global core.editor subl
## set default usename/email
git config --global user.name "yahyaKacem"
git config --global user.email "[email protected]"
## store the $PATH and aliases to check on logout if during the
## current session the user make some changes to them and on logout save
## changes to $PATH and aliases in files and notify user about them
mkdir -p -m a=rwx "/tmp/bash_tmp/"
alias | md5sum > "/tmp/bash_tmp/aliases1"
echo $PATH | md5sum > "/tmp/bash_tmp/path1"
### some helper functions
## recursive-statistics-on-file-types-in-directory
### source http://unix.stackexchange.com/questions/18506/recursive-statistics-on-file-types-in-directory
files_stats() {
find $1 -type f | sed 's/.*\.//' | sort | uniq -c
}
## github create repository helper
github-create() {
repo_name=$1
dir_name=`basename $(pwd)`
if [ "$repo_name" = "" ]; then
echo "Repo name (hit enter to use '$dir_name')?"
read repo_name
fi
if [ "$repo_name" = "" ]; then
repo_name=$dir_name
fi
username=`git config github.user`
if [ "$username" = "" ]; then
echo "Could not find username, run 'git config --global github.user <username>'"
invalid_credentials=1
fi
token=`git config github.token`
if [ "$token" = "" ]; then
echo "Could not find token, run 'git config --global github.token <token>'"
invalid_credentials=1
fi
if [ "$invalid_credentials" == "1" ]; then
return 1
fi
echo -n "Creating Github repository '$repo_name' ..."
curl -u "$username:$token" https://api.github.com/user/repos -d '{"name":"'$repo_name'"}' > /dev/null 2>&1
echo " done."
echo -n "Pushing local code to remote ..."
git remote add origin [email protected]:$username/$repo_name.git > /dev/null 2>&1
git push -u origin master > /dev/null 2>&1
echo " done."
}
# update stuff
clns () {
sudo aptitude clean
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get clean
sudo aptitude purge `dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'`
}
upg () {
sudo apt upgrade -y
}
up () {
sudo apt update
}
upg_no_up () {
upg
clns
}
upg_no_clns () {
up
upg
}
full_update_clns () {
up
upg
clns
}
clearCache() {
sync;echo 3 > /proc/sys/vm/drop_caches
}
###-begin-ng-completion###
#
# ng command completion script
#
# Installation: ng completion >> ~/.bashrc (or ~/.zshrc)
#
ng_opts='new init build serve generate autocomplete e2e format lint test version'
init_opts='--dry-run --verbose --blueprint --skip-npm --skip-bower --name'
new_opts='--dry-run --verbose --blueprint --skip-npm --skip-bower --skip-git --directory'
build_opts='--environment --output-path --watch --watcher'
serve_opts='--port --host --proxy --insecure-proxy --watcher --live-reload --live-reload-host
--live-reload-port --environment --output-path --ssl --ssl-key --ssl-cert'
generate_opts='component directive pipe route service'
test_opts='--watch --browsers --colors --log-level --port --reporters'
if type complete &>/dev/null; then
_ng_completion() {
local cword pword opts
COMPREPLY=()
cword=${COMP_WORDS[COMP_CWORD]}
pword=${COMP_WORDS[COMP_CWORD - 1]}
case ${pword} in
ng) opts=$ng_opts ;;
i|init) opts=$init_opts ;;
new) opts=$new_opts ;;
b|build) opts=$build_opts ;;
s|serve|server) opts=$serve_opts ;;
g|generate) opts=$generate_opts ;;
test) opts=$test_opts ;;
esac
COMPREPLY=( $(compgen -W '${opts}' -- $cword) )
return 0
}
complete -o default -F _ng_completion ng
elif type compctl &>/dev/null; then
_ng_completion () {
local words cword opts
read -Ac words
read -cn cword
let cword-=1
case $words[cword] in
ng) opts=$ng_opts ;;
i|init) opts=$init_opts ;;
new) opts=$new_opts ;;
b|build) opts=$build_opts ;;
s|serve|server) opts=$serve_opts ;;
g|generate) opts=$generate_opts ;;
test) opts=$test_opts ;;
esac
setopt shwordsplit
reply=($opts)
unset shwordsplit
}
compctl -K _ng_completion ng
fi
###-end-ng-completion###