-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zprofile
155 lines (127 loc) · 3.63 KB
/
.zprofile
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
# Prompt and title
precmd () {print -Pn "\e]0;%~\a"}
export PROMPT="%m:%~$ "
# Search
alias grep='grep --exclude-dir=".venv" --exclude-dir=".git"'
# Navigation
alias ls='ls --color'
alias ll='ls -alhG'
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
# Git
alias gs='git status'
alias gd='git diff'
alias ga='git add'
alias gc='git commit -m'
function gtouch {
touch $1
git add --intent-to-add $1
}
# yadm
alias ys='yadm status'
alias yd='yadm diff'
alias ya='yadm add'
alias yc='yadm commit -m'
# Misc
alias cat='bat'
alias sudo='sudo '
# ARM Development
export GCC_PATH=/Applications/ARM/bin
# Python
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init --path)"
fi
export PYTHONSTARTUP="${HOME}/.startup.py"
export PATH="$HOME/python_scripts:$PATH"
export PYTHONBREAKPOINT=ipdb.set_trace
# Vim
alias vim='nvim'
export EDITOR=nvim
export SYSTEMD_EDITOR="$EDITOR"
export FCEDIT="$EDITOR"
export VISUAL="$EDITOR"
export SUDO_EDITOR="$EDITOR"
# Secrets
test -f ~/.zsecrets && source ~/.zsecrets
# System specific stuff
test -f ~/.zsystem && source ~/.zsystem
# Kitty nonsense
#alias ssh="kitty +kitten ssh"
# python applications
export PATH="$HOME/.local/bin:$PATH"
if [[ `uname` == "Darwin" ]]; then
# MacOS
eval "$(/opt/homebrew/bin/brew shellenv)"
alias brew='arch -arm64 brew'
else
# debian
export PATH=$PATH:/snap/bin
source /usr/share/doc/fzf/examples/key-bindings.zsh
fi
# misc keybindings
bindkey "\E[1~" beginning-of-line
bindkey "\E[4~" end-of-line
bindkey "\E[H" beginning-of-line
bindkey "\E[F" end-of-line
bindkey "\E[3~" delete-char
bindkey "^[OF" end-of-line
bindkey "^[OH" beginning-of-line
# Kill all unattached tmux sessions.
alias tmux-clean="tmux ls | grep -v attached | awk -F: '{print \$1}' | xargs -I{} tmux kill-session -t {}"
# Pushes to the remote that the PR was created from
# Useful for open source projects that allows maintainers to edit
# Requires "brew install jq"
# Requires "brew install github/gh/gh"
function pr_push {
ORG_AND_REPO=$(git remote get-url origin | sed -E 's/^.*github.com[:\/]?([^\/]*)\/(.*)\.git$/\1\/\2/')
REMOTE_URL=$(curl https://api.github.com/repos/$ORG_AND_REPO/pulls/${1:?"The PR number must be specified"} | jq .head.repo.ssh_url | tr -d '"')
BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Going to execute: git push $REMOTE_URL $BRANCH"
$(git push $REMOTE_URL $BRANCH)
}
# Push equivalent of https://cli.github.com/manual/gh_pr_checkout
# gh pr push <pr_number>
gh() {
if [ "$1" = "pr" ] && [ "$2" = "push" ]; then
pr_push $3
else
command gh "$@"
fi
}
# QMK
export QMK_HOME='~/projects/qmk_firmware'
# PngCrush
# Function to pngcrush all PNG files in the current directory
pngcrush_all() {
if command -v pngcrush >/dev/null; then
for file in ./*.png; do
if [ -f "$file" ]; then
pngcrush -ow -brute "$file"
echo "Compressed: $file"
fi
done
else
echo "Error: pngcrush is not installed. Please install it and try again."
fi
}
function cumulative_size() {
if [[ $# -ne 2 ]]; then
echo "Usage: cumulative_size <folder_path> <extension>"
return 1
fi
folder_path="$1"
extension="$2"
if [[ ! -d "$folder_path" ]]; then
echo "Error: '$folder_path' is not a valid directory"
return 1
fi
total_size=0
while IFS= read -r -d '' file; do
file_size=$(stat -f%z "$file")
total_size=$((total_size + file_size))
done < <(find "$folder_path" -type f -iname "*.${extension}" -print0)
formatted_size=$(printf "%'.f" "$total_size")
echo "Cumulative size of all .${extension} files in '${folder_path}': ${formatted_size} bytes"
}