-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.aliasrc
More file actions
224 lines (197 loc) · 6.45 KB
/
Copy path.aliasrc
File metadata and controls
224 lines (197 loc) · 6.45 KB
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
alias .='nvim .'
alias en="nvim $HOME/git/dotfiles/.config/nvim/init.lua"
alias brewu='brew update && brew upgrade && echo "Pinned package not upgraded:" && brew list --pinned'
alias bro=brew
alias bye="sh $HOME/git/worktime/bye.sh"
alias c='clear'
alias ckw='gdate +"Current calendar week: %U"'
alias clc='fc -ln -1 | pbcopy'
alias dco='docker compose' #hehe
alias doc='docker compose'
alias dotf='source $HOME/git/dotfiles/.env'
alias ed='tmux new-window "nvim ~/git/dotfiles"'
alias gcam='git add $1 && git commit -m . && git status'
alias gcm='git checkout master && git pull'
alias gl='git pull'
alias gp='git push'
alias grep='grep --color=auto'
alias gst='git status'
alias intip='ifconfig | grep "inet " | grep -v 127.0.0.1'
alias k='kubectl'
alias ll='gls -lash --color=auto --group-directories-first'
alias ll='ls -lash'
alias loadnvm='[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"'
alias ls='ls --color=auto'
alias nr='npm run'
alias pick='git log -300 --oneline --color $1 | fzf -m --ansi --preview "git show --color {1}" | awk "{print $1}"'
alias pp='curl --max-time 5 -s parrot.live'
alias sdf='source ~/git/dotfiles/.aliasrc'
alias tf=terraform
alias tfa='terraform apply --auto-approve'
alias tfd='terraform destroy --auto-approve'
alias gcb='git checkout $(git branch -a | grep -v "\->" | sed "s/^..//; s#remotes/[^/]*/##" | sort -u | fzf)'
function cbox () {
# launch claude with the current dir as volume mount
export REPO_DIR="$(cd "$PWD" && pwd -P)" # resolve symlinks
local proj="claude-$(basename "$REPO_DIR")"
local dFile="$HOME/git/claude-docker/docker-compose.yml"
docker compose -p "$proj" -f $dFile down
docker compose -p "$proj" -f $dFile up -d
docker compose -p "$proj" -f $dFile exec claude claude "$@"
docker compose -p "$proj" -f $dFile down
}
function showf () {
# shows all functions in .aliasrc
file_to_grep="$HOME/git/dotfiles/.aliasrc"
RED='\033[0;31m'
NC='\033[0m' # No Color
grep -A 1 -w '^function' "$file_to_grep" | awk -v red="$RED" -v nc="$NC" '
/function/ {
printf "%s%s%s %s ", red, $1, nc, $2
getline
print
}' | sort
}
function notes () {
# open notes file in new tmux window
tmux new-window -n notes "nvim ~/notes.md"
tmux select-pane -t 0
}
functions ghc () {
# gh repo clone for sealsystems org and cd into it
gh repo clone sealsystems/$1
cd $1
ls -lash
}
function drm () {
# docker remove container and start it again detached
name=$(basename "$PWD")
dco kill $1 || true
docker rm "$name"-"$1"-1; dco up -d "$1"
}
function dcol () {
# displays docker compose logs in a human readable table
docker compose logs $1 --no-log-prefix \
| grep -E '^\{.*\}$' \
| fx 'x => `${x.isoTimestamp} ${x.message} ${JSON.stringify(x.metadata, null, 2)}`'
}
function ghw () {
# opens repo in browser
b=$(git rev-parse --abbrev-ref HEAD)
gh repo view -w -b $b
}
function dcols () {
# creates dco log session
tmux new-window "docker compose logs -f $1"
shift
for i in "$@"; do
tmux split-window -h "docker compose logs -f $i"
tmux select-layout even-horizontal
done
tmux select-pane -t 0
}
function ghclone () {
# clones github repos via fzf
gh repo clone sealsystems/$(cat ~/.repos | fzf --sync --height 60% --reverse --select-1 --query "'${1}")
}
function npmc () {
# clean npm installation
echo 'Removing package-lock.json'
echo 'Removing node_modules folder'
rm -rf package-lock.json node_modules
echo 'Run `npm install`'
npm i
}
function npmu () {
# npm update dependencies
cd $(git rev-parse --show-toplevel)
npm outdated
ncu --upgrade
rm package-lock.json
npm i
}
function dld () {
# displays last 5 working days
find $HOME/git/worktime/files -type f | sort -n | tail -5 | xargs -I % echo "echo ---; echo % | cut -d "/" -f7; cat %" | sh
}
function dps () {
# pretty docker ps
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.State}}\t{{.CreatedAt}}"
}
function mock () {
# spongebob mock
MOCK=$(node -p "process.argv.slice(1).map(w => w.split('').map((c)=>Math.random()<=0.5?c.toUpperCase():c.toLowerCase()).join('')).join(' ')" $*)
echo $MOCK
echo $MOCK | pbcopy
}
function co (){
# adds co-authored to git commit message
for handle in "$@"
do
echo "Co-authored-by: $handle <$handle@users.noreply.github.com>"
done
}
function extip () {
# shows external ip addres
curl -4 ifconfig.me/ip
}
function fizy () {
# no info
find . -type d \( -path ./node_modules -o -path ./.git \) -prune -o -type f | fzy
}
function ghh () {
# returns to git repos root
cd $(git rev-parse --show-toplevel)
}
function pkey () {
# copies public key to clipboard
cat ~/.ssh/id_rsa.pub | xclip -selection clipboard
}
function gdi () {
# pretty git diff
preview="git diff $@ --color=always -- {-1}"
git diff $@ --name-only | fzf -m --ansi --preview $preview
}
function fzb () {
# no info
local files
IFS=$'\n' files=($(fzf --preview 'bat {-1} --color=always')) && nvim "${files[@]}"
}
function dwipe () {
# wipes all docker containers/volumes/...
echo "Stopping and removing all containers"
docker kill $(docker container ls -aq)
echo "Removing all stopped containers, networks, dangling images and build cache"
docker system prune --force --volumes
}
function dcores () {
# restarts ($1/all) docker container(s)
echo `Stopping, removing, restarting and attaching to $1`
docker compose kill $1 && docker compose rm $1 -f && docker compose up -d && docker compose logs -f $1
}
function iwipe () {
# wipes ($1/all) docker image(s)
if [ -n "$1" ]; then
docker rmi "$1"
else
docker image prune -a -f
fi
}
function update-node () {
# updates node to seal version
PREVIOUS_NODE_VERSION=$(nvm version)
GITHUB_TOKEN=${GITHUB_TOKEN:-`grep authToken $HOME/.npmrc | sed -r 's|//npm.pkg.github.com/:_authToken=(.*)$|\1|'`}
NODE_VERSION=`curl -sf -H 'Cache-Control: no-cache' "https://$GITHUB_TOKEN@raw.githubusercontent.com/sealsystems/generator-seal-node/master/lib/constants.js" | grep "NODE_VERSION" | cut -f2 -d"'"`
[ $NODE_VERSION ]
nvm install --default $NODE_VERSION --reinstall-packages-from=$PREVIOUS_NODE_VERSION || echo "NODE_VERSION not found, invalid GITHUB_TOKEN?"
}
function oib () {
#open git repo in browser without gh installed
if git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
repo_url=$(git config --get remote.origin.url)
repo_path=$(echo "$repo_url" | sed -E 's/.*github.com[:\/](.*)\.git/\1/')
echo "$repo_path" | xargs -I {} open -a "Zen Browser" "https://github.com/{}"
else
echo "E: Not inside a repository."
fi
}