Repository navigation
Expand file tree
/
Copy path.zshrc
More file actions
178 lines (145 loc) · 4.37 KB
/
Copy path.zshrc
File metadata and controls
178 lines (145 loc) · 4.37 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
# detect OS to have platform-specific settings
platform='unknown'
os_name=$(uname -s | tr '[:upper:]' '[:lower:]')
case "${os_name}" in
linux*)
platform='linux'
;;
darwin*)
platform='macos'
;;
*)
>&2 echo "Operating system ${os_name} is not supported."
exit 1
;;
esac
if [ -f "$HOME/.profile" ]; then
source "$HOME/.profile"
fi
if [ ! -d "$HOME/.zim" ]; then
curl -fsSL https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
else
source $HOME/dotfiles/.zim-zshrc
fi
# basic path settings
if [[ $platform == 'linux' ]]; then
export PATH=$HOME/.local/bin:/usr/local/bin:$PATH
dist=`lsb_release -si`
if [[ $dist == "Arch" ]]; then
function update_pkg () {
MAKEFLAGS="-j$(nproc)" yay -Syu
}
else
function update_pkg () {
sudo apt -yy update
sudo apt -yy upgrade
sudo apt -yy autoremove
}
fi
elif [[ $platform == "macos" ]]; then
function update_pkg () {
brew update
brew upgrade
brew cleanup -s
softwareupdate --all --install --force
}
fi
function pip-install-basics () {
pip install -U wheel pip setuptools
pip install python-language-server flake8
}
function update-all () {
pushd $HOME/dotfiles
git pull --rebase --autostash
popd
rustup update
update_pkg
cargo install $(cargo install --list | egrep '^[a-z0-9_-]+ v[0-9.]+:$' | cut -f1 -d' ')
}
function install-esp-idf () {
readonly port=${1:?"The version must be specified. https://github.com/espressif/esp-idf/tags"}
rm -rf $HOME/esp
mkdir -p $HOME/esp
cd $HOME/esp
git clone -b $1 --recursive https://github.com/espressif/esp-idf.git
cd $HOME/esp/esp-idf
./install.sh all
}
function cleanup_git {
git remote prune origin
git fetch -p && git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D
git branch -vv | grep -v "\]" | awk '{print $1}' | xargs git branch -D
}
function kitty-theme {
THEME_FILE="$HOME/.kitty-themes/themes/$1"
# Check if the theme file exists
if [ ! -f "$THEME_FILE" ]; then
echo "Theme file does not exist: $THEME_FILE"
return 1
fi
ln -s -f "$THEME_FILE" "$HOME/.config/kitty/theme.conf"
kitty @ set-colors -a -c "$THEME_FILE"
}
# Load compinit if not already loaded
if (( ! ${+functions[compdef]} && ! ${+functions[compadd]} )); then
autoload -Uz compinit
compinit
fi
function _complete_kitty_theme {
local -a theme_files
theme_files=(${(f)"$(find $HOME/.kitty-themes/themes/*.conf -exec basename {} \;)"})
_describe 'theme file' theme_files
}
compdef _complete_kitty_theme kitty-theme
zmodload zsh/zprof
if [[ $platform == "macos" ]]; then
if [ ! -d "/opt/homebrew" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
eval "$(/opt/homebrew/bin/brew shellenv)"
source $HOME/dotfiles/homebrew-github-token.sh
fi
# locale!
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
# fix text rendering
# https://unix.stackexchange.com/questions/598440/zsh-indic-fonts-support-rendering-issue-which-is-working-fine-on-bash
setopt COMBINING_CHARS
# python
export PYTHON_CONFIGURE_OPTS="--enable-shared"
export KICAD_PARTS="$HOME/Developer/kicad-parts"
# golang
export PATH="$HOME/go/bin:$PATH"
# rust
if [ -d "$HOME/.cargo" ]; then
export PATH="$HOME/.cargo/bin:$PATH"
else
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi
# javascript
export PATH="./node_modules/.bin:$PATH"
eval "$(fnm env)"
export EDITOR="nvim"
# thefuck
if whence -cp thefuck &> /dev/null; then
eval $(thefuck --alias)
fi
alias mux="tmuxinator"
# Install zsh-async if it’s not present
if [ ! -d ~/.zsh-async ]; then
git clone git@github.com:mafredri/zsh-async.git ~/.zsh-async
fi
source ~/.zsh-async/async.zsh
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# nnn preview
export NNN_FIFO=/tmp/nnn.fifo
export NNN_PLUG='1:ipinfo;p:preview-tui;o:fzz;b:nbak'
# aliases
alias gitlog='git log --oneline --date-order --graph --since="yesterday" --decorate'
alias ls='eza -gls type --color=always'
alias vim='nvim'
alias ssh='TERM=xterm-256color ssh'
alias nnn='nnn -a -H -Pp'
alias pbcopy="xsel --clipboard --input"
alias pbpbaste="xsel --clipboard --output"
alias espenv="source /opt/esp-idf/export.sh"