forked from jordi9/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 3
/
me.plugin.zsh
147 lines (118 loc) · 4.46 KB
/
me.plugin.zsh
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
# Exports
#########
# Set desired java version
#export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home
#export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
# Set locale properly
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export KAFKA_HOME=$HOME/.bin/kafka_2.12-2.2.0
export PATH=/usr/local/opt/gettext/bin:$PATH:$KAFKA_HOME/bin
# Aliases
#########
alias homecnf="cd ~/.homesick/repos/dotfiles"
alias cnf="vim ~/.homesick/repos/dotfiles/me.plugin.zsh"
alias zcnf="vim ~/.zshrc"
alias acnf="vim ~/.zsh/antigenrc.zsh"
alias reload="source ~/.zshrc"
alias redis-start="cd ~/.redis && redis-server ~/.redis/redis.conf"
# Avoid stupid gradle or gradlew from oh-my-zsh gradle plugin
alias gradle="gradle"
alias mvn="mvn"
alias ge="gradle"
alias fucking="sudo"
alias s="ssh"
alias dc="docker-compose"
alias d="docker"
alias hs="homesick"
alias d-stop-all='docker stop $(docker ps -a -q)'
alias d-kill-all='docker kill $(docker ps -a -q)'
# Git
#####
alias gf="git fetch"
alias gpf="gp --force-with-lease"
alias gpub='gp -u origin `g rev-parse --abbrev-ref HEAD`'
alias gri="g r -i master"
# https://stackoverflow.com/questions/20433867/git-ahead-behind-info-between-master-and-branch
alias gah='g rev-list --left-right --count master...`g rev-parse --abbrev-ref HEAD`'
alias gmdd='g log -1 --pretty=%B > commit.md'
alias gmde='code commit.md'
alias gmdc='g ci -F commit.md'
function gl {
local old_rev="$(git rev-parse HEAD)"
git pull
local new_rev="$(git rev-parse HEAD)"
if [[ -n $old_rev && $old_rev != $new_rev ]]; then
echo Updated from ${old_rev:0:7} to ${new_rev:0:7}.
git --no-pager log --oneline --reverse --no-merges --stat '@{1}..'
fi
}
alias gl=gl
# https://ben.lobaugh.net/blog/201616/cleanup-and-remove-all-merged-local-and-remote-git-branches
alias g-delete-merged-branches="gb --merged | grep -v '\*' | grep -v master | xargs -n 1 git branch -d && g remote prune origin"
# Gradle
#####
function gradle-create-subproject {
local name=$1
mkdir "$name"
mkdir -p "$name"/src/test/kotlin
mkdir -p "$name"/src/main/kotlin
touch "$name/build.gradle.kts"
echo "include \"$name\"" | pbcopy
echo "include string ready to be pasted in settings.gradle.kts"
}
# Mac
#####
# Reload Dock
alias reload-dock="killall Dock"
# Add a spacer to the left side of the Dock (where the applications are)
alias add-dock-spacer="defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type=\"spacer-tile\";}' && reload-dock"
# Do not disturb, stop bouncing
alias do-not-disturb="defaults write com.apple.dock no-bouncing -bool TRUE && reload-dock"
alias disturb="defaults write com.apple.dock no-bouncing -bool FALSE && reload-dock"
## High Sierra dark mode for mojave https://www.tekrevue.com/tip/only-dark-menu-bar-dock-mojave/
# System Preferences > General and select Light for Appearance
alias high-sierra-dark-on="defaults write -g NSRequiresAquaSystemAppearance -bool Yes"
# Logout. System Preferences > General and select Dark for Appearance
alias high-sierra-dark-off="defaults delete -g NSRequiresAquaSystemAppearance"
# Brew
#######
function cask-install {
COMMAND=(brew cask install $1)
if $COMMAND; then
print $COMMAND >> ~/.homesick/repos/dotfiles/Caskfile
print "👌 Saved in Caskfile"
fi
}
# https://www.client9.com/using-macos-homebrew-to-install-a-specific-version/
function brew-versions-search {
formula=$1
git -C "$(brew --repo homebrew/core)" log master -- Formula/$formula.rb
}
function brew-versions-install {
brewurl=https://raw.githubusercontent.com/Homebrew/homebrew-core
formula=$1
sha=$2
brew install ${BREWURL}/$sha/Formula/$formula.rb
}
# Linux
#######
alias x='xclip -selection clipboard'
# Misc
######
alias copy-mysql-driver="cp ~/.m2/repository/mysql/mysql-connector-java/5.1.26/mysql-connector-java-5.1.26.jar ."
alias xmas='curl climagic.org/txt/jb.txt | while read -r c n l;do printf "\e[1;${c}m%${COLUMNS}s\e[0m\n" " ";play -q -n synth pl $n trim 0 $l;done'
alias fix-htop-permissions="sudo chown root:wheel /usr/local/bin/htop && sudo chmod u+s /usr/local/bin/htop"
# Audophile
###########
function transcode {
echo 'Transcoding FLAC files to 16-bit'
mkdir resampled # make a subdirectory to put our files in
for file in *.flac
do
newfile=`echo "$file" | sed "s/ /_/g"`
mv "$file" "$newfile" # get rid of filename spaces to avoid errors
sox -S $newfile -b 16 -r 44100 "resampled/$newfile" # resample
mv "$newfile" "$file" # put stuff back the way we found it
done
}