-
Notifications
You must be signed in to change notification settings - Fork 3
/
.aliases
executable file
·183 lines (148 loc) · 5.26 KB
/
.aliases
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#!/bin/bash
################################################################################
### Configure System-Wide Aliases
################################################################################
# See https://hub.github.com/hub-sync.1.html
function tellus-sync() {
for dir in $HOME/Documents/Projects/tellus*; do
if [[ "$dir" =~ tellus-core ]]; then
: # No-op
else
echo "hub sync on $dir"
( cd $dir && hub sync )
fi
done
BACKEND_DIR="$HOME/Documents/Projects/zilly-backend"
echo "hub sync on $BACKEND_DIR"
( cd $BACKEND_DIR && hub sync )
}
alias plistbuddy="/usr/libexec/PlistBuddy"
function s() {
PARAM=$1
if [[ $PARAM = "all" || $PARAM = "a" ]]; then
tellus-sync
echo "hub sync on fastlane/fastlane"
(
cd $HOME/Documents/Projects/fastlane && hs
)
else
echo "hub sync on $PARAM"
( cd ~/Documents/Projects/$PARAM && hub sync )
fi
}
# Opens a Sourcetree window using the given path, if needed.
# Example: `sourcetree .` opens a new Sourcetree window for the current directory
# or focuses on the open one if there's one open already.
function sourcetree() {
open -a Sourcetree "$1"
}
alias st=sourcetree
alias gt='gittower -n'
function doit() {
gt "$1"
txt "$1"
}
function txt() {
# Sublime Text
# "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" "$1"
# VS Code
# open -a "Visual Studio Code.app" $1
# Cursor
open -a "Cursor.app" $1
}
# This command kills and relaunches several audio and bluetooth related processes,
# fixing issues bluetooth headsets malfunctioning.
function killaudio() {
sudo kill `pgrep coreaudiod`
sudo kill `pgrep bluetoothd`
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
sudo kextunload -b com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport
}
# Usage:
# update-target someorg:perhapsabranch
function update-target() {
TARGET="$1" # e.g. 'someoneelse:anotherbranch' or 'revolter/fix-slack-head-branch' or 'rogerluan-fix-important-feature'
BASE_ORG=$(giturl | awk -F'[:/]' '{print $2}')
REPO_NAME=$(giturl | awk -F'[:/]' '{print $3}' | sed 's/.git$//')
if [[ $TARGET =~ : ]]; then
echo "Updating a branch from a fork"
bash $DOTFILES_DIR/Utilities/update_fork.sh --base-org:$BASE_ORG --repo-name:$REPO_NAME --target:$TARGET
else
echo "Updating a branch of the same repo"
bash $DOTFILES_DIR/Utilities/update_branch.sh --base-org:$BASE_ORG --repo-name:$REPO_NAME --target:$TARGET
fi
}
# gpg-agent eventually dies, randomly, failing to sign commits. This command kills existing gpg-agent process and relaunches it.
alias killgpg="pkill gpg-agent && gpg-agent --daemon"
# Opens the Google Play Store console (beta view), ready to publish a new version of the app
alias playstore="open -a safari https://play.google.com/console/u/1/developers/6280656057399977520/app-list"
# Generates a UUID
alias uuid=uuidgen
# Alias to hub_patched_sync
alias hs=hub_patched_sync
# Attempts to clean up local branches once they don't exist in remote anymore
function hub_patched_sync() {
# First run it once, to sync everything.
hub sync
# Then run it a second time to collect the branches that weren't deleted, and delete them.
hub_sync_results=$(hub sync 2>&1)
swift $DOTFILES_DIR/Utilities/delete_local_branches_from_hub_sync.swift "$hub_sync_results"
}
alias python=python3
# Prettifies the input json file into an output file
function json() {
SRC="$1"
SRC_FILENAME="${SRC%%.*}" # Removes the .json extension
DST="$SRC_FILENAME-prettier.json"
cat $SRC | python -mjson.tool > $DST
echo "Prettified JSON and saved it at '$DST'"
}
# Generates a git changelog from the current directory from the parameter's tag to current HEAD.
function changelog() {
git log --pretty='* %s' "$1"...HEAD | grep "* #"
}
# Generates a git changelog from the current directory from the parameter's tag to current HEAD.
function changelog-md() {
CHANGELOG=$(changelog $1)
# OPEN_PRS=$(gh pr list)
sed -E 's/#(\d*)/[#$1](https:\/\/github.com\/zillyinc\/tellus-ios\/pull\/$1)/gm' <<< $CHANGELOG
# sed -Ei "s/^([[:blank:]]*)(pod 'Reveal-SDK')/\1# \2/" Podfile
}
alias cl=changelog
alias clmd=changelog-md
# Prints the PATH env var in a user-friendly way
alias path="tr ':' '\n' <<< \"$PATH\""
function sha256() {
set +H
echo -n "$1" | openssl dgst -sha256
set -h
}
function md5() {
set +H
echo -n "$1" | openssl dgst -md5
set -h
}
alias giturl="git config --get remote.origin.url"
# Prints the incoming argument backwards
function reverse() {
awk 'BEGIN{FS=""} {for (i=NF; i>0; i--) s=s $i; print s}' <<< "$1"
}
# Converts time from a "hour:minute:second" format to decimal.
function time_to_d() {
ruby $DOTFILES_DIR/Utilities/time_to_decimal.rb "$1"
}
function develop_diff() {
git diff develop:"$1" "$1" > "$1".patch
}
function master_diff() {
git diff master:"$1" "$1" > "$1".patch
}
alias typo="typos --config $DOTFILES_DIR/.typos.toml"
function git_checkout_fork() {
ruby $DOTFILES_DIR/Utilities/git_checkout_fork.rb "$@"
}
alias tinfoil="/Users/rogerluan/Documents/Nintendo\ Switch/infra/TinfoilWebServer --config $DOTFILES_DIR/TinfoilWebServer.config.json"
function rgbtohex() {
ruby $DOTFILES_DIR/Utilities/rgb_to_hex.rb "$@"
}