-
Notifications
You must be signed in to change notification settings - Fork 0
/
sharedconfig.sh
114 lines (90 loc) · 2.12 KB
/
sharedconfig.sh
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
#!/bin/bash
# Replace this files with your own config
set -euo pipefail
function _list() {
echo "gc"
echo "gcp"
echo "ghc"
echo "ghct"
echo "gm"
echo "touchSh"
echo "rmf"
echo "openzsh"
echo "openhome"
echo "replaceSymlink"
}
function gc() {
local message="${1:-updates}"
git add -A
git commit -m "$message"
}
function gcp() {
local flags="$3"
gc "$1"
if [ -z "$flags" ]; then
git push
else
git push "$flags"
fi
}
function ghc() {
local owner="$1"
local name="$2"
local flags="$3"
if [ -z "$owner" ]; then
echo "Enter the owner of the repo to clone."
read -r owner
fi
if [ -z "$name" ]; then
echo "Enter the name of the repo to clone."
read -r name
fi
if [ -z "$flags" ]; then
git clone --recurse-submodules "[email protected]:$owner/$repo.git"
else
git clone --recurse-submodules "$flags" "[email protected]:/$owner/$repo.git"
fi
}
function ghct() {
local repo="$1"
local flags="$2"
ghc "ted-marozzi" "$repo" "$flags"
}
alias gm="git stash && git checkout main || git checkout master || git checkout develop && git pull"
function touchsh() {
local filename="$1"
if [ -z "$filename" ]; then
echo "Enter the filename to create (without an extension)."
read -r filename
fi
# Strip .sh if the user entered it
filename=${filename%".sh"}
printf '#!/bin/bash\nset -euo pipefail\n' >"$filename.sh"
chmod +x "./$filename.sh"
}
function kp() {
npx kill-port "$1"
}
alias openzsh="code ~/.zshrc"
alias openhome="code ~"
function replaceSymlink() {
sourcefile=$(readlink "$1")
rm "$1" && cp -a "$sourcefile" "$1"
}
function replaceAllSymlinks() {
find ./ -type l -exec sh -c 'for i in "$@"; do replaceSymlink $1; done' bash {} +
}
# start: vim config
set -o vi
function zle-keymap-select() {
case $KEYMAP in
vicmd) echo -ne '\e[1 q' ;; # block
viins | main) echo -ne '\e[5 q' ;; # beam
esac
}
zle -N zle-keymap-select
function ip() {
ipconfig getifaddr en0
}
# end: vim config
set +euo pipefail