-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.zsh.functions
More file actions
72 lines (61 loc) · 1.52 KB
/
.zsh.functions
File metadata and controls
72 lines (61 loc) · 1.52 KB
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
# find git branch into folders
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# restart postgres
pgr() {
kill `ps -ef | grep postgres | grep -v grep | awk '{print $2}'`
}
#execute python's PIP without a virtualenv
syspip(){
PIP_REQUIRE_VIRTUALENV="" pip "$@"
}
pihole_disable() {
ssh pi@addams.local 'pihole disable 1m'
}
pre_commit() {
mix format; mix credo; mix dialyzer --format github;
}
#########################################
# BASH UTILITIES FOR DOCKER
# Author: Nicolas Baptista <nicolas@onyo.com>
# Source this file in your .bash_profile
#########################################
alias d='docker'
alias dl='docker ps -l -q'
alias dc='docker-compose'
#Stops and remove all containers
docker_cleanup(){
printf "Stoping all docker containers\n"
docker stop $(docker ps -a -q);
printf "Removing all docker containers\n"
docker rm $(docker ps -a -q);
}
#Open the bash on a specific container
docker_enter_container(){
local LAST=false
local ERROR=false
readonly container=${1:?"Container id must be specified or use -L option to enter latest running container"}
case "$1" in
-l|-L)
local LAST=true
;;
\?)
local ERROR=true
;;
esac
if [[ "$ERROR" == true ]]
then
printf "Incorrect option\n"
elif [[ "$LAST" == true ]]
then
docker exec -it $(dl) /bin/bash || docker exec -it $(dl) /bin/sh
elif [ $1 ]
then
printf "Entering $1 container\n"
docker exec -it $1 /bin/bash || docker exec -it $1 /bin/sh
fi
}
docker_logs(){
docker-compose logs -f;
}