-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.functions
148 lines (125 loc) · 3.47 KB
/
.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
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
#!/bin/bash
# Functions
# Make directory and cd into it
m() {
mkdir $1 && cd $_
}
# Create file and open it
to() {
touch $1 && open $_
}
# Commit w/o doing pre-commit checks
lookMomNoHands() {
git commit --no-verify -m "$1"
}
# Sometimes you need to commit nothing
emptycommit() {
git commit --allow-empty -m "$1"
}
dockerRestart() {
docker-compose down
docker-compose up
}
# Get "into" a given container
dockerssh() {
docker exec -it $1 bash
}
# Returns the process that's running on a port
onport() {
lsof -i :$1
}
# Kills whatever is running on a specified port
killport() {
kill -9 "$(lsof -i :$1 -t)"
}
# Installs a new version of node, including installing all the old packages
installnode () {
current="$(node -v)"
nvm install $1 --reinstall-packages-from="${current}"
nvm use $1
nvm alias default $1
}
# More thorough npm install
npmin() {
rm -rf node_modules/
npm cache clean
npm i
}
# Search for a git branch
fb() {
git branch | grep $1
}
findBranch() {
git branch | grep $1
}
# List the files that have been added or modified since your last commit
gFileDiff() {
echo
git diff --name-only `git rev-parse --abbrev-ref HEAD`
echo
}
# Clone and npm install
gclone() {
git clone $1 && npm install
}
# Push to the origin of the current branch
gpusho() {
current="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
git push origin $current
}
# Commit
gc() {
g commit -m $1
}
gcommit() {
g commit -m $1
}
# Jump over to develop, pull, then go back to the branch you were on and merge with local develop
mergeDev() {
current="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
git checkout develop && git pull origin develop && git checkout $current && git merge develop
}
merge_main() {
current="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
git checkout main && git pull origin main && git checkout $current && git merge main
}
# Jump over to master, pull, then go back to the branch you were on and merge with local master
merge_master() {
current="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
git checkout master && git pull origin master && git checkout $current && git merge master
}
# Kill all ongoing webpack processes
killwebpack() {
ps aux|grep -i "node\s.*webpack" | awk '{print $2}' | xargs kill -9
}
# Other/Extras
whatsmyIP() {
dig +short myip.opendns.com @resolver1.opendns.com
}
camerausedby() {
echo "Checking to see who is using the iSight camera… 📷"
usedby=$(lsof | grep -w "AppleCamera\|USBVDC\|iSight" | awk '{printf $2"\n"}' | xargs ps)
echo -e "Recent camera uses:\n$usedby"
}
# Some configuration stuff for `npm init`
config_npm() {
npm config set init.author.name "Dave Lunny"
npm config set init.author.email "[email protected]"
npm config set init.author.url "himynameisdave.com"
npm config set init.license "MIT"
}
gpgSetLocalKey() {
git config --local user.signingkey $1
git config --local commit.gpgsign true
}
versionsof() {
npm view $1 versions
}
# Open the Pull Request URL for your current directory's branch (base branch defaults to main)
openpr() {
github_url=`git remote -v | awk '/fetch/{print $2}' | sed -Ee 's#(git@|git://)#https://#' -e 's@com:@com/@' -e 's%\.git$%%' | awk '/github/'`;
branch_name=`git symbolic-ref HEAD | cut -d"/" -f 3,4`;
default_branch=`git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@'`;
pr_url=$github_url"/compare/"$default_branch"..."$branch_name
open $pr_url;
}