-
Notifications
You must be signed in to change notification settings - Fork 0
/
zsh_include.sh
282 lines (229 loc) · 7.54 KB
/
zsh_include.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# SETUP: Put these in your zshrc
##################
# Helpful go to your by pressing gf on: ~/.zshrc
# https://github.com/lukechilds/zsh-better-npm-completion
# plugins=(git macos lol vi-mode web-search wd fasd httpie tig tmux fzf gh)
# . ~/settings/shared/zsh_include.sh
# Source Brew
# Brew default
function source_if_exists() {
[ -f $1 ] && source $1
}
function eval_w_param_if_exists() {
[ -f $1 ] && eval $($1 $2)
}
# TODO: consider doing this in a loop as it's really annoying to have 3 configurations
eval_w_param_if_exists ~/homebrew/bin/brew shellenv
eval_w_param_if_exists /home/linuxbrew/.linuxbrew/bin/brew shellenv
export EDITOR=nvim
# C-T search Files Fuzzy
# C-R Search History fuzzy
source_if_exists ~/.fzf.zsh
source_if_exists ~/homebrew/etc/profile.d/z.sh
PATH+=:~/.local/bin
alias ghgmd='gh gist create --filename=out.md --'
alias alf="open '/Applications/Alfred 5.app/'"
alias charge="system_profiler SPPowerDataType | grep Watt"
alias imgls='timg --grid 4 --title'
alias lg='lazygit'
alias gfrall='for git_directory in * ; echo $git_directory && git -C $git_directory fr'
alias gpushall='for git_directory in * ; echo $git_directory && git -C $git_directory push'
alias weather="curl wttr.in/seattle"
alias dwc='pushd ~/gits/settings && python3 -c "from vim_python import * ;WCDailyPage()" && pushd ~/gits/igor2/750words '
alias dgc='pushd ~/gits/settings && python3 -c "from vim_python import * ;GitCommitDailyPage()" && pushd ~/gits/igor2/750words '
alias sl='ssh lightsail'
alias slnf='ssh lightsail_no_forward'
alias tam='tmux attach-session -t main || tmux new-session -s main'
alias ytsub='youtube-dl --write-sub --sub-format srt --skip-download'
alias ghe="gh copilot explain"
alias ghs="gh copilot suggest"
# Looks like pbcopy just works over ssh/mosh now!
# alias rpbcopy='~/settings/rpbcopy.sh'
alias rpbpaste='~/settings/rpbpaste.sh'
# alias rpbc='~/settings/rpbcopy.sh'
# alias rpbc='~/settings/pbcopy'
alias rpbp='~/settings/rpbpaste.sh'
alias pbc='pbcopy'
alias pbp='pbpaste'
# Use rich markdown pager
alias rmp='rich - -m'
alias tmuxp="~/.local/bin/tmuxp"
alias mb="pbpaste | sed 's!idvork.in/!idvorkin.azurewebsites.net/!'| sed 's!#!/!' | pbcopy"
function echomb() {
echo $1 > ~/tmp/mb.in
cat ~/tmp/mb_tmp | sed 's!idvork.in/!idvorkin.azurewebsites.net/!'| sed 's!#!/!' > ~/tmp/mb.out
cat ~/tmp/mb.out | pbc
cat ~/tmp/mb.out
}
unalias ddg
function ddg() {
dg grateful $1
}
function ddt() {
dg todo $1
}
function dda() {
dg awesome $1
}
function ijm() {
~/gits/nlp/life.py journal-report --u4 $1 $2 $3 $4
}
function ijv() {
ij body --close $1 | vim -
}
function journal_gpt() {
# $1 date
# $2 command
~/igor_journal.py entries $1 | while read line; do echo && echo \#\#\#\ $line && ~/igor_journal.py body $line | ~/gits/nlp/mood.py $2 ; done | tee ~/tmp/$2_for_$1.md
}
function alias_if_exists() {
# $1 - alias
# $2 - replacement command
which $2 &> /dev/null
if [[ $? -eq 0 ]] ; then
alias $1=$2
else
echo "program $2 not found"
fi
}
function alias_if_other_exists() {
# $1 - alias
# $2 - replacement command
# $3 - command to test for
which $3 &> /dev/null
if [[ $? -eq 0 ]] ; then
alias $1=$2
else
echo "program $2 not found"
fi
}
function do_wsl() {
echo "in WSL"
alias pbcopy='clip.exe'
}
if [[ "$(uname -a)" =~ "microsoft" ]]; then
do_wsl
fi
function gstatdaterange() {
# $1 - start
# $2 - end
# can be days ago
# glogdate '30 days ago' '1 day ago'
# or absolute dates
# glogdate '12/01/2020'
# output all git commits since until, pretty print to just have the commit
git_output=`git log --since "$1" --until "$2" --pretty="%H"`
# diff between first commit to last commit, and sort the output by size
#sort params -k=second column; -t=with delimter as |; -n=sort as numeric -r sort as reversed
git diff --stat `echo $git_output | tail -n 1` `echo $git_output | head -n 1` | sort -k2 -t'|' -n -r
}
function rhyme()
{
# Call Rhyme using the rhymebrain API
# jq - https://stedolan.github.io/jq/manual/#Basicfilters
# rhymebrain API - https://rhymebrain.com/api.html
http "https://rhymebrain.com/talk?function=getRhymes&word=$1" | jq '.[] | select( .score == 300) |.word'
}
function go_home()
{
pkill -9 Workplace
pkill Outlook
# figure out how to kill the tabs ...
}
function go_work()
{
open -g '/Applications/Microsoft Outlook.app'
open -g '/Applications/Workplace Chat.app'
# figure out how to kill the tabs ...
work_cli
}
function work_cli()
{
wchat threads
cal dump
}
eval "$(zoxide init zsh)"
eval "$(mcfly init zsh)"
# Set alias that are always better
alias_if_exists cat bat
alias_if_exists ls exa
alias_if_exists df duf
alias_if_exists top htop
alias_if_exists ndcu gdu
alias_if_exists du dua
alias_if_other_exists cd z zoxide
alias_if_exists ps procs
# Igor setups use Soed and Sodot as useful aliases
alias Soed='nvim ~/settings/shared/zsh_include.sh'
alias Sodot='. ~/settings/shared/zsh_include.sh'
function png_shrink()
{
pngquant -f -o $1 $1
}
function cs_install_brew()
{
# install brew - much faster to default location
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/codespace/.profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
}
function pbfix()
{
pbpaste > ~/tmp/gpt.ipc.in
cat ~/tmp/gpt.ipc.in | ~/gpt3.py fix | tee ~/tmp/gpt.ipc.out
delta ~/tmp/gpt.ipc.in ~/tmp/gpt.ipc.out
echo "Press any key to continue..."
read
cat ~/tmp/gpt.ipc.out | pbcopy
echo "Clipboard updated, you can back original by running"
echo "~/tmp/gpt.ipc.in | pbcopy"
}
function esecret_jq() {
export "$1"=$(jq -r .$1 ~/gits/igor2/secretBox.json)
export | grep $1
}
function export_secrets()
{
esecret_jq LANGCHAIN_API_KEY
export OPENAI_API_KEY=$(jq -r '.openai' ~/gits/igor2/secretBox.json)
export GOOGLE_API_KEY=$(jq -r '.googleapikey' ~/gits/igor2/secretBox.json)
export BRAVE_SEARCH_API_KEY=$(jq -r '.brave' ~/gits/igor2/secretBox.json)
export BING_SUBSCRIPTION_KEY=$(jq -r '.bing' ~/gits/igor2/secretBox.json)
export BING_SEARCH_URL='https://api.bing.microsoft.com/v7.0/search'
echo $OPENAI_API_KEY
}
# Some useful work aliases
alias chh='wchat messages'
alias thr='wchat threads'
alias grtd="grep ☐"
function rtd()
{
ssh lightsail_no_forward cat /home/ec2-user/gits/igor2/750words/$(date +'%Y-%m-%d').md | grep ☐ | pbcopy
pbpaste
}
function nvday()
{
nvim scp://ec2-user@lightsail//home/ec2-user/gits/igor2/750words/$(date +'%Y-%m-%d').md
}
# Useful stuff w/OSX Sound
alias restart_audio='sudo launchctl kickstart -kp system/com.apple.audio.coreaudiod'
alias airpods_audio='SwitchAudioSource -s "Igor’s AirPods Pro" && SwitchAudioSource -t input -s "Igor’s AirPods Pro" '
# Turn off auto update brew
export HOMEBREW_NO_AUTO_UPDATE=1
# Setting this allows lip gloss to use truecolor
# Man, what a PITA
export COLORTERM=truecolor
set -o vi
set nobell
# shared zsh settings to be sourced
# TMUX attach
# I'm not sure why, but ruby can't find the linuxbrew path
# export LD_LIBRARY_PATH=/home/linuxbrew/.linuxbrew/lib:/opt/homebrew/lib
bindkey -M viins 'fj' vi-cmd-mode
source ~/settings/shared/fzf_git_keybindings.zsh
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export STARSHIP_CONFIG=~/settings/shared/starship.toml
eval "$(starship init zsh)"
eval $(thefuck --alias)
eval "$(rbenv init -)"
echo "zsh_include complete"