-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaliases
More file actions
113 lines (111 loc) · 8.76 KB
/
Copy pathaliases
File metadata and controls
113 lines (111 loc) · 8.76 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
#!/usr/bin/env zsh
# profile self update
alias update_profile='git -C $SHA1N_PROFILE_HOME pull origin $(git -C $SHA1N_PROFILE_HOME branch --show-current); git -C $SHA1N_PROFILE_HOME submodule update --init --recursive'
alias reload!='for f in $SHA1N_PROFILE_HOME/load.zsh $SHA1N_PROFILE_HOME/include/*(.) $SHA1N_PROFILE_HOME/scripts/lib.zsh; do [[ $f == *.zwc ]] && continue; zcompile $f 2>/dev/null; done; source $HOME/.zshrc'
#
# directory shortcuts
#
alias home='cd $HOME'
alias back='cd $OLDPWD'
alias cod='cd $HOME/code'
alias cow='cd $HOME/code/w'
alias gos='cd $(go env GOPATH)/src/github.com/sha1n'
# main task conventions
alias main='cd -P $HOME/main'
#
# command shortcuts
#
alias cdz='cd $(dirname $(fzf --height 50%))'
alias vim='nvim'
alias vimz='vim -o $(fzf -m --height 50%)'
alias vimd='vim -d $(fzf -m --height 50%)'
alias grep='grep --color=auto'
# Claude Code
alias clauded='claude --debug'
alias claudem='find $HOME/.claude/projects -iname memory.md -type f'
alias claude_stats='jq -r '\''"--- CLAUDE CODE STATS (cumulative) ---", "", "Sessions started: \(.numStartups)", "First session: \(.firstStartTime | split("T")[0])", "Prompt queue uses: \(.promptQueueUseCount) (queued prompts sent while busy)", "Projects worked on: \(.projects | length) (directories used with Claude)", "", "--- Skills ---", "Unique skills used: \(.skillUsage | length)", "Total skill runs: \(.skillUsage | [.[].usageCount] | add)", "", "Most used:", (.skillUsage | to_entries | sort_by(.value.usageCount) | reverse | .[0:5] | .[] | " \(.value.usageCount | tostring | if length < 2 then " \(.) " else " \(.)" end) \(.key) (last: \(.value.lastUsedAt / 1000 | strftime("%Y-%m-%d")))")'\'' $HOME/.claude.json'
alias claude_skills_stats='jq -r '\''"--- SKILL USAGE (cumulative, \(.skillUsage | length) skills, \(.skillUsage | [.[].usageCount] | add) total runs) ---", "", (.skillUsage | to_entries | sort_by(-.value.usageCount) | .[] | "\(.value.usageCount | tostring | (4 - length) * " " + .)\(" " + .key + ((35 - (.key | length)) * " "))\(.value.lastUsedAt / 1000 | strftime("%Y-%m-%d"))")'\'' $HOME/.claude.json'
alias claude_last_session_stats='echo "--- LAST SESSION PER PROJECT (each row = most recent session only) ---" && echo && (echo "Cost|In/Out|+Lines|-Lines|Duration|Project" && jq -r '\''.projects | to_entries | map(select(.value.lastCost > 0)) | sort_by(-.value.lastCost) | .[] | "\(.value.lastCost | tostring | split(".") | .[0] + "." + (.[1] + "00")[0:2] | "$" + .)|\((.value.lastTotalInputTokens + .value.lastTotalCacheReadInputTokens) / 1000 | floor | tostring + "k")/\(.value.lastTotalOutputTokens / 1000 | floor | tostring + "k")|\(.value.lastLinesAdded)|\(.value.lastLinesRemoved)|\(.value.lastDuration / 1000 / 60 | floor | tostring + "m")|\(.key | split("/") | last)"'\'' $HOME/.claude.json) | column -t -s "|"'
alias claude_last_model_stats='echo "--- MODEL USAGE (from last session per project, not cumulative) ---" && echo && (echo "Cost|In/Out|Cache read|Searches|Model" && jq -r '\''[.projects[].lastModelUsage // {} | to_entries[]] | group_by(.key) | map({model: .[0].key, projects: length, input: (map(.value.inputTokens) | add), output: (map(.value.outputTokens) | add), cache_read: (map(.value.cacheReadInputTokens) | add), cost: (map(.value.costUSD) | add), searches: (map(.value.webSearchRequests) | add)}) | sort_by(-.cost) | .[] | "$\(.cost | tostring | split(".") | .[0] + "." + (.[1] + "00")[0:2])|\(.input / 1000 | floor | tostring + "k")/\(.output / 1000 | floor | tostring + "k")|\(.cache_read / 1000000 | . * 10 | floor / 10 | tostring + "M")|\(.searches)|\(.model)"'\'' $HOME/.claude.json) | column -t -s "|"'
alias claude_last_snapshot='jq -r '\''.projects | to_entries | map(.value) | map(. + {lastCost: (.lastCost // 0), lastTotalInputTokens: (.lastTotalInputTokens // 0), lastTotalOutputTokens: (.lastTotalOutputTokens // 0), lastTotalCacheReadInputTokens: (.lastTotalCacheReadInputTokens // 0), lastTotalCacheCreationInputTokens: (.lastTotalCacheCreationInputTokens // 0), lastLinesAdded: (.lastLinesAdded // 0), lastLinesRemoved: (.lastLinesRemoved // 0), lastDuration: (.lastDuration // 0), lastAPIDuration: (.lastAPIDuration // 0), lastToolDuration: (.lastToolDuration // 0), lastTotalWebSearchRequests: (.lastTotalWebSearchRequests // 0)}) | "--- SNAPSHOT (summed from last session per project, not cumulative) ---", "", "Cost: $\(map(.lastCost) | add | . * 100 | floor / 100)", "Input tokens: \(map(.lastTotalInputTokens) | add | . / 1000 | floor)k", "Output tokens: \(map(.lastTotalOutputTokens) | add | . / 1000 | floor)k", "Cache read tokens: \(map(.lastTotalCacheReadInputTokens) | add | . / 1000000 | . * 10 | floor / 10)M", "Cache write tokens: \(map(.lastTotalCacheCreationInputTokens) | add | . / 1000000 | . * 10 | floor / 10)M", "Cache hit ratio: \((map(.lastTotalCacheReadInputTokens) | add) as $cr | (map(.lastTotalInputTokens) | add) as $in | (map(.lastTotalCacheCreationInputTokens) | add) as $cc | ($cr / ($cr + $in + $cc) * 100 | floor))% of all input tokens", "", "Lines added: \(map(.lastLinesAdded) | add)", "Lines removed: \(map(.lastLinesRemoved) | add)", "Net lines: \(map(.lastLinesAdded - .lastLinesRemoved) | add)", "", "Session time: \(map(.lastDuration) | add / 1000 / 3600 | . * 10 | floor / 10)h", "API time: \(map(.lastAPIDuration) | add / 1000 / 60 | . * 10 | floor / 10)m", "Tool execution time: \(map(.lastToolDuration) | add / 1000 / 60 | . * 10 | floor / 10)m", "Web searches: \(map(.lastTotalWebSearchRequests) | add)"'\'' $HOME/.claude.json'
# ls
alias ll='ls -lh'
alias la='ls -lha'
# git
alias master='git checkout master'
alias status='git status'
alias reset='git reset'
alias add='git add'
alias commit='git commit'
alias stash='git stash'
alias pop='git stash pop'
alias gil='git log --abbrev=8 --pretty=format:"%C(red)%as%C(reset) %C(green)%h%C(reset)%C(auto)%d%C(reset) %s - %C(cyan)[%ce]%C(reset)"'
alias pull='git pull --ff-only --autostash origin $(git branch --show-current)'
alias pull_master='git pull --rebase --autostash origin master'
alias pullmr='git pull --ff-only --recurse-submodules origin master'
alias push='git push origin $(git branch --show-current)'
alias pushf='git push --force-with-lease origin $(git branch --show-current)'
alias branch='git branch'
alias checkout='git checkout'
alias gc_branches='git branch | grep -v "^* $(git branch --show-current)$" | xargs git branch -D'
alias gc_worktrees="git worktree list --porcelain | awk '/^worktree / { if (++count > 1) print substr(\$0, 10) }' | xargs -I {} git worktree remove '{}'"
alias sync_submodules='git submodule update --init --recursive'
# gh
alias pr='gh pr create'
alias prs='gh pr list'
alias myprs='gh pr list -A sha1n'
alias issues='gh issue list'
alias releases='gh release list'
alias clone='gh repo clone'
alias rview='gh repo view -w'
# glab
alias gpr='glab mr create'
alias gprs='glab mr list'
alias gmyprs='glab mr list --author sha1n'
alias gissues='glab issue list'
alias greleases='glab release list'
alias gclone='glab repo clone'
alias grview='glab repo view -w'
# make
alias maket='make test'
alias makev='make format lint test'
# yarn/npm
alias yi='yarn install'
alias yt='y run test'
alias yit='y run test:it'
alias yut='y run test:unit'
alias yb='y run build'
alias yc='y run clean'
alias yl='yarn run lint'
alias yr='yi && yc && yb'
alias rm_node_modules='find . -type d -name node_modules -exec rm -rf {} +'
# kubectl
alias k='kubectl'
alias ke='kubectl get events --sort-by=".lastTimestamp"'
alias kenn='kubectl get events --sort-by=".lastTimestamp" --field-selector type!=Normal'
alias kc='kubectl --kubeconfig'
# bazel
alias bazel='bazel_with_disk_cache_guard'
alias bazel_rm='sudo rm -rf ~/.cache/bazel'
# dockerized mysql
alias mysqld8='docker run -v "/tmp/mysql_mount/":/var/lib/mymysql -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -p 3306:3306 mysql:8 --secure-file-priv=""'
# maven
alias mvn1='mvn verify -amd -pl'
alias mvnci='mvn -T 1C clean install'
alias mvncv='mvn -T 1C clean verify'
alias mvnq='mvn -T 1C clean install -DskipTests'
alias mvndl='mvn dependency:list'
alias mvndt='mvn dependency:tree'
alias mvndr='mvn dependency:resolve -U'
alias mvnpls='mvn dependency:purge-local-repository -DsnapshotsOnly=true'
alias mvnpl='mvn dependency:purge-local-repository'
# filters out non first degree dependencies from 'mvndt' output
alias mvndtt='mvndt | grep --color=never -F "[INFO] +- " | tr -d "[INFO] +- "'
alias mvnsv='mvn versions:set -DnewVersion='
# utilities
alias uuid="uuidgen | awk '{print tolower(\$0)}'"
alias history='history 1'
alias diff='diff --side-by-side --suppress-common-lines'
# backup
alias backup="rsync -a --delete --delete-during -P --force --exclude=\".*\" \"$BACKUP_SRC_PATH\" \"$BACKUP_DST_PATH\""
alias studio_backup="zsh $CODE/studio-backup/run_backup.sh"