-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.bash.functions
More file actions
75 lines (65 loc) · 1.5 KB
/
.bash.functions
File metadata and controls
75 lines (65 loc) · 1.5 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
73
74
75
# 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 "$@"
}
workon_hub() {
cd /Users/nbap/workspace/hub/repos/hubcode;
}
workon_doorman() {
cd /Users/nbap/workspace/hub/repos/doorman;
pipenv shell;
}
#########################################
# 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'
#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(){
LAST=false
ERROR=false
local OPTIND o a
while getopts ":lL" opt; do
case "$opt" in
l|L)
LAST=true
;;
\?)
ERROR=true
;;
esac
done
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
else
printf "You must pass the container id\n"
fi
}
docker_logs(){
docker-compose logs -f;
}