-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaliases.zshrc
125 lines (108 loc) · 3.51 KB
/
aliases.zshrc
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
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Aliases to load
alias startredis="redis-server /usr/local/etc/redis.conf"
alias startmongo="brew services start [email protected]"
alias restartmongo="brew services restart [email protected]"
alias stopmongo="brew services stop [email protected]"
alias allowsleep="sudo pmset -a disablesleep 0"
alias disablesleep="sudo pmset -a disablesleep 1"
alias viewsettings="pmset -g"
alias reset_audio="sudo kill -9 `ps ax|grep 'coreaudio[a-z]' | awk '{print $1}'`"
alias start_kafka="zookeeper-server-start /usr/local/etc/kafka/zookeeper.properties & kafka-server-start /usr/local/etc/kafka/server.properties"
alias commit="git commit -S"
alias port_scan="lsof -nP +c 15 | grep LISTEN"
# Variable declarations
last_branch='master'
# Functions
# Switch into dev and reset it to the origin.
# Then merge changes (from the branch you switched from) into dev
# Usage: pull_reset_merge_into_dev
function pull_reset_merge_into_dev() {
branch=$(git symbolic-ref --short -q HEAD)
last_branch=$branch
git checkout dev
git fetch
git reset --hard origin/dev
git merge $branch
}
function pull_merge_into_dev() {
branch=$(git symbolic-ref --short -q HEAD)
last_branch=$branch
git checkout dev
git pull
git merge $branch
}
# Checkout a branch and reset it to it's origin
# Usage: pull_reset_to {branch name}
function pull_reset_to() {
branch=$(git symbolic-ref --short -q HEAD)
last_branch=$branch
git checkout "$1"
git reset --hard origin/"$1"
}
# Checkout a branch and pull from it's origin
# Usage: checkout_pull {branch name}
function checkout_pull(){
branch=$(git symbolic-ref --short -q HEAD)
last_branch=$branch
git checkout "$1"
git pull
}
# Push your current branch to remote and add upstream reference
# Usage: push_first_time
function push_first_time() {
branch=$(git symbolic-ref --short -q HEAD)
git push --set-upstream origin $branch
}
# Checkout remote branch
# Usage: remote_checkout {branch name}
function remote_checkout(){
branch=$(git symbolic-ref --short -q HEAD)
last_branch=$branch
git fetch
git checkout "$1"
}
# This will rebase the latest changes from master unto your current branch
# Usage: update_branch_to_master
function update_branch_to_master() {
branch=$(git symbolic-ref --short -q HEAD)
git checkout master
git fetch
git reset --hard origin/master
git checkout $branch
git rebase master
}
# This goes to previous branch after running certain commands.
# Supported commands are `pull_reset_merge_into_dev`, `pull_reset_to`, `checkout_pull`, `remote_checkout`
# Usage: go_to_last
function go_to_last(){
branch=$(git symbolic-ref --short -q HEAD)
git checkout "$last_branch"
last_branch=$branch
}
function file_count() {
find . -maxdepth 1 -type f | wc -l
}
function prune_git_branches() {
git checkout master
git branch | grep -ve " master$" | xargs git branch -D
}
function initial_commit_hash(){
$(git log master.."$branch" --oneline | tail -1 | cut -d ' ' -f1)
}
function resign() {
git rebase --exec 'git commit --amend --no-edit -n -S' -i master
}
function do_curl() {
curl -vvv "$1"
}
function do_openssl() {
openssl s_client -connect "$1"
}