-
Notifications
You must be signed in to change notification settings - Fork 0
/
.shell_functions
77 lines (58 loc) · 1.98 KB
/
.shell_functions
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
function updog {
printf "\nUpdating...\n" \
&& sudo apt update \
&& sudo apt -y dist-upgrade \
&& sudo apt -y autoremove \
&& sudo apt -y autoclean \
&& ver
}
# cd up N directories - ".. 3" goes up 3
function .. {
if [ -n "$1" ]; then
NUM=$(grep -o '[0-9]\+' <<< "$1")
START=0
while [ "$START" -lt "$NUM" ]; do
\cd ..
START=$((START+1))
done
else
\cd ..
fi
}
function fdcd {
[ -n "$1" ] \
&& docker-compose -f "$1" down \
|| docker-compose down
}
# bring down either the current dir's docker-compose.yml's container stack, or a specified file, with "dcre ~/.docker/stack1/prod-compose.yml"
function dcre {
if [ $# -eq 0 ]; then
docker-compose down \
&& docker-compose pull \
&& docker-compose up -d
elif [ ! $# -eq 0 ]; then
docker-compose -f "$1" down \
&& docker-compose -f "$1" pull \
&& docker-compose -f "$1" up -d
else
printf "\nNo compose file specified\n"
fi
}
### Oneliners
function dotsetup { bash ./shell_setup.sh && clear && printf "\nDone\n\n"; }
function dcstrm { docker container stop "$1" && docker container rm "$1"; }
function grope { sudo touch "$1" && sudo "$EDITOR" "$1"; } # (forcibly) touch file, then (forcibly) edit
function mkcd { mkdir -p "$1" && cd "$1" || exit; } # create directory, then change to that dir
function source_vim { echo | vim +"so %"; } # reload vim configuration
function source_tmux { tmux source-file ~/.tmux.conf; } # reload tmux configuration
function source_bashrc { source "$HOME"/.bashrc; } # reload bashrc
function source_zshrc { source "$HOME"/.zshrc; } # reload zshrc
function flushdns { systemd-resolve --flush-caches; }
function network-restart { /etc/init.d/networking restart; }
function bak { cp "$1"{,.bak}; }
function what { grep -niT "$1" "${DOT_LOC}"/.shell_{aliases,functions}; }
function where { grep --initial-tab --recursive --line-number --ignore-case "$1"; }
function helm_repo_version { helm search repo "$1" --versions; }
makemine() {
sudo chown "$USER":"$USER" "$1"
}