-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
138 lines (124 loc) · 3.22 KB
/
.zshrc
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
#!/bin/zsh
### Aesthetics
PS1=$'[%(?.%F{green}√.%F{red}X)%f][%*][%F{red}%1d%f]: '
touch ~/.hushlogin
export CLICOLOR=1
export LSCOLORS=gafacadabaegedabagacad
### Misc Behavior Mod
export HOMEBREW_NO_ANALYTICS=1
autoload -U select-word-style
select-word-style bash
setopt AUTO_CD
setopt NO_CASE_GLOB
PROMPT_COMMAND="history -a; history -n"
unsetopt correct
### History
PROMPT_COMMAND="history -a; history -n"
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
setopt EXTENDED_HISTORY
HISTCONTROL=ignoreboth
setopt SHARE_HISTORY
setopt INC_APPEND_HISTORY
setopt APPEND_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_IGNORE_DUPS
setopt HIST_FIND_NO_DUPS
setopt HIST_REDUCE_BLANKS
HISTIGNORE="ls:ll:pwd:bg:fg:history"
bindkey '^P' history-beginning-search-backward
bindkey '^N' history-beginning-search-forward
HISTSIZE=20000
export SAVEHIST=$HISTSIZE
echo "setup settings"
### Utils
alias cat="bat"
alias ls="eza"
alias sudo='sudo '
alias rm="trash"
alias blacklist="sudo emacs /etc/hosts"
alias la="ls -a"
alias sexit="killall Terminal"
alias cleanup="bash ~/scripts/cleanup.sh"
alias activate='source venv/bin/activate'
alias venv='python3 -m venv venv; activate'
alias sizeof="du -sh"
alias ca="conda activate"
alias cda="conda deactivate"
alias vi="emacs -Q -nw"
alias vie="emacs -Q -nw"
alias vim="vi"
alias hgrep="history 0 | grep"
alias spruce_up="rm ~/.Trash/*; brew cleanup; brew update; brew upgrade; brew cleanup; sudo shutdown -r now"
function lc {
fc -ln -1 | awk '{$1=$1}1' | pbcopy
}
function jjq {
jq -R -r "${1:-.} as \$line | try fromjson catch \$line"
}
function notify {
title=$1
body=$2
osascript -e "display notification \"${body}\" with title \"${title}\""
}
function git_push {
message=$1
git add .
git commit -m "$message"
git push
}
function p() {
if [[ -f "package-lock.json" ]]; then
# if command is "i" or "install"
# we want to run npm install, not npm run install
if [[ "$1" == "i" || "$1" == "install" ]]; then
npm install
else
npm run "$@"
fi
elif [[ -f "yarn.lock" ]]; then
if [[ "$1" == "i" || "$1" == "install" ]]; then
yarn
else
yarn "$@"
fi
elif [[ -f "pnpm-lock.yaml" ]]; then
pnpm "$@"
elif [[ -f "bun.lock" ]]; then
bun "$@"
else
echo "No recognized lock file found."
fi
}
function sizeup {
dir=$1
dir="${dir:-$(pwd)}"
du -hx "${dir}" | sort -n | tail -200
}
function porthog {
PORT=$1
lsof -iTCP -sTCP:LISTEN -P | grep "$PORT"
}
function gen_gif {
in_file=$1
in_base=$(basename "$in_file" | cut -d. -f1)
ffmpeg -i "$in_file" -pix_fmt rgb24 -r 10 "$in_base.gif"
}
### Emacs
export EDITOR='emacsclient --create-frame --alternate-editor=""'
alias emc='emacsclient --no-wait --create-frame --alternate-editor=""'
alias emcnw='emacsclient -tty --create-frame --alternate-editor=""'
alias kille="emacsclient -e '(kill-emacs)'"
alias remc="kille;emc && exit"
function em {
if [ "$#" -eq 0 ]; then
echo "Starting new Emacs process ..." >&2
emacs & disown
elif emacsclient -n "$@" 2> /dev/null; then
echo "Opened $* in Emacs server" >&2
else
echo "Opening $* in a new Emacs process ..." >&2
emacs "$@" & disown
fi
}
echo "setup utils"
echo "Loaded .zshrc"