-
Notifications
You must be signed in to change notification settings - Fork 0
/
.aliases
213 lines (171 loc) · 6.82 KB
/
.aliases
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
alias edit_aliases="nano ~/.aliases && source ~/.aliases"
#
# system aliases
#
alias x="chmod +x"
alias lsla="ls -lha"
alias lsl="ls -l"
alias lsline='ls $@ | tr "\n" " "'
alias lns="ln -s"
alias cd..="cd .."
alias cd...="..."
alias mkd="mkdir -p"
# TODO: mkdcp
alias tail_ls='chshell() { chsh -s $(which "$1") ;}; chshell'
alias ls_tail='ls_tail() { ls -l "$1" | tail ;}; ls_tail'
alias folder_size='folder_size() { du -sh "$1" ;}; folder_size'
alias t=' && echo yes || echo no'
alias crontablog="sudo grep CRON /var/log/syslog"
install_pkg_manager="yum"
alias install="sudo ${install_pkg_manager} install"
alias installdeb="sudo dpkg -i"
alias update="sudo ${install_pkg_manager} update"
alias upgrade="sudo ${install_pkg_manager} upgrade"
alias upgradable="install_pkg_manager list --upgradable"
upgradable-list_func() {
upgradable | tail -n +2 | awk -F'/' '{print $1}' | tr '\n' ' '
}
alias upgradable-list="upgradable-list_func"
alias upgradable-list-new="upgradable | tail -n +2 | awk '{split($0,a,"/"); print a[1]}' | tr '\n' ' '"
alias remove="sudo ${install_pkg_manager} remove"
alias autoremove="sudo apt-get autoremove"
alias dist-upgrade="sudo apt-get dist-upgrade"
alias sources="sudo nano /etc/apt/sources.list"
alias filesBySize="du -ah $1 | grep -v "/$" | sort -rh"
alias filesBySizeLimited="du -ah $1 | grep -v "/$" | sort -rh | head -10"
alias s="source"
#
# Programs aliases
#
alias openvpn="sudo service openvpn"
alias openvpn_start="openvpn start"
alias nomachine="sudo /etc/NX/nxserver"
alias nomachine_restart="nomachine --restart"
#
# Docker
#
get_container_id_by_name() { get_container_id=$(docker container ls -a --filter name="$1" | tail -n +2 | awk '{print($1)}');};
docker_enter() {
docker run -i "$1" /bin/bash
};
alias di="docker images"
alias docker_list_containers_all='docker container ls -a -q | tr "\n" " "'
alias docker_stop_all='docker stop $(docker ps -a -q | tr "\n" " ")' # stop all containers
alias docker_rm_cont_all='docker rm $(docker ps -a -q | tr "\n" " ")' # remove all containers
alias docker_list_images_all='docker images -q | tr "\n" " "' # list all docker images
alias docker_rm_images_all='docker rmi -f $(docker_list_images_all)' # remove all docker images
alias docker_list_volumes_all='docker volume ls -q | tr "\n" " "' # list all volumes images
alias docker_rm_volumes_all='docker volumes rm $(docker_list_volumes_all)' # remove all docker volume
alias docker_clean_all="docker_stop_all; docker_rm_cont_all; docker_rm_images_all"
htpasswd_docker() { docker run --rm httpd:2.4-alpine htpasswd -nbB ${1} ${2} ;};
# portainer
# https://github.com/portainer/portainer
get_portainer_container_id() { get_container_id_by_name "portainer" && portainer_container_id=${get_container_id} ;};
dockerGUI_func() {
#portainer_container_id=$(get_portainer_container_id)
# portainer_container_id=$(docker container ls -a --filter name="portainer" | tail -n +2 | awk '{print($1)}')
#if [[ ${portainer_container_id} != "" ]] ; then
# # echo "Remove old portainer container: ${portainer_container_id}"
# docker stop ${portainer_container_id} &> /dev/null
# docker rm -v -f ${portainer_container_id} &> /dev/null
# docker rmi -f ${portainer_container_id} &> /dev/null
#fi
docker rm portainer > /dev/null
docker rmi portainer/portainer:latest > /dev/null
docker run -d -p 9000:9000 --name portainer \
--restart always \
-v /var/run/docker.sock:/var/run/docker.sock \
portainer/portainer \
-H unix:///var/run/docker.sock \
--no-auth \
&> /dev/null && \
firefox "http://0.0.0.0:9000/#/dashboard" &> /dev/null && \
wmctrl -r "Portainer" -t 8
};
alias dockerGUI="dockerGUI_func &"
alias portainer="dockerGUI"
alias htop-docker="docker run --rm -it --pid host frapsoft/htop"
# ctop
# https://github.com/bcicen/ctop
ctop_docker() {
docker run --rm -ti \
--name=ctop \
-v /var/run/docker.sock:/var/run/docker.sock \
quay.io/vektorlab/ctop:latest
};
alias ctop_docker="ctop_docker"
alias ctop="ctop_docker"
# dive
# https://github.com/wagoodman/dive
dive() {
docker run --rm -it \
-v /var/run/docker.sock:/var/run/docker.sock \
wagoodman/dive:latest
};
# dockviz
# https://github.com/justone/dockviz
alias dockviz="docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock nate/dockviz"
######
# Personal aliases
######
alias branch="azdo-new-branch"
alias us="pezaio-new-us-from-us"
#
# my git aliases
#
new-repo() {
fullRepoPath="$1"; repoNameGit=$(basename "$fullRepoPath"); repoName="${repoNameGit%.*}"; mkdir -p ~/REPOSITORIOS/$repoName
};
alias git-clone='git-clone() { fullRepoPath="$1"; repoNameGit=$(basename "$fullRepoPath"); repoName="${repoNameGit%.*}"; mkdir -p ~/REPOSITORIOS/$repoName; git clone "$1"}; git-clone'
alias git-new='git-new() { fullRepoPath="$1"; repoNameGit=$(basename "$fullRepoPath"); repoName="${repoNameGit%.*}"; mkdir -p ~/REPOSITORIOS/$repoName; echo "# $repoName" >> README.md; git init; git add README.md; git commit -m "first commit"; git remote add origin $1; git push -u origin master}; git-new'
alias git-update-branch-from-dev="git pull origin develop"
alias git-gui="git gui &> /dev/null &"
alias ggui=git-gui
# my repos aliases
alias start_ETSIINFBot="~/REPOSITORIOS/ETSIINFbot/yii start/updates"
alias stop_ETSIINFBot="~/REPOSITORIOS/ETSIINFbot/yii start/stop-hook"
#
# androtest && AoD
#
get_androtest_container_id() { androtest_container_id=$(docker ps -a | grep androtest | awk '{print $1}');};
docker_stop_androtest() {
# get_androtest_container_id()
androtest_container_id=$(docker ps -a | grep androtest | awk '{print $1}')
if [[ ${androtest_container_id} == "" ]] ; then
echo "Any androtest container running"
else
docker stop ${androtest_container_id}
fi
};
docker_enter_androtest-test() {
TOOL=$1
C=androtest-test-${TOOL:-puma}
AP=~/REPOSITORIOS/androtest-test
[[ ! -d $AP ]] && echo "dir: $AP - not exist" && exit 1
cd $AP
docker run --publish-all --privileged \
-v $(pwd)/lib:/home/vagrant/lib:rw \
-v $(pwd)/results:/home/vagrant/results:rw \
-v $(pwd)/subjects:/home/vagrant/subjects:rw \
-v $(pwd)/scripts:/home/vagrant/scripts:rw \
-v $(pwd)/tools:/home/vagrant/tools:rw \
-i $C /bin/bash
};
alias adc="docker build --tag androtest-docker ."
alias ade="docker run --interactive --rm --tty androtest-docker bash"
alias up_run1="cd ~/vagrant/androtest && vagrant up run1 && cd"
alias down_run1="cd ~/vagrant/androtest && vagrant halt run1 && cd"
alias ssh_run1="ssh [email protected] -p 2222"
alias start_run1="up_run1 && ssh_run1"
alias up_run2="cd ~/vagrant/androtest && vagrant up run2 && cd"
alias down_run2="cd ~/vagrant/androtest && vagrant halt run2 && cd"
alias ssh_run2="ssh [email protected] -p 2200"
alias start_run2="up_run2 && ssh_run2"
# others
ic_docker() {
opts=$@
cd ~/REPOSITORIOS/imdea-controls-cli_gitlab/
make OPTS="$opts"
cd - > /dev/null
};
alias ic="ic_docker"