Created
February 14, 2023 15:34
-
-
Save LufsX/41e83d127c2d266526bb6903df3277fb to your computer and use it in GitHub Desktop.
My .zshrc file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Added by Zinit's installer | |
if [[ ! -f $HOME/.local/share/zinit/zinit.git/zinit.zsh ]]; then | |
print -P "%F{33} %F{220}Installing %F{33}ZDHARMA-CONTINUUM%F{220} Initiative Plugin Manager (%F{33}zdharma-continuum/zinit%F{220})…%f" | |
command mkdir -p "$HOME/.local/share/zinit" && command chmod g-rwX "$HOME/.local/share/zinit" | |
command git clone https://github.com/zdharma-continuum/zinit "$HOME/.local/share/zinit/zinit.git" && \ | |
print -P "%F{33} %F{34}Installation successful.%f%b" || \ | |
print -P "%F{160} The clone has failed.%f%b" | |
fi | |
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh" | |
autoload -Uz _zinit | |
(( ${+_comps} )) && _comps[zinit]=_zinit | |
# Load a few important annexes, without Turbo | |
# (this is currently required for annexes) | |
zinit light-mode for \ | |
zdharma-continuum/zinit-annex-as-monitor \ | |
zdharma-continuum/zinit-annex-bin-gem-node \ | |
zdharma-continuum/zinit-annex-patch-dl \ | |
zdharma-continuum/zinit-annex-rust | |
### End of Zinit's installer chunk | |
# # The theme for zsh | |
# zinit ice depth=1; zinit light romkatv/powerlevel10k | |
# POWERLEVEL9K_DISABLE_CONFIGURATION_WIZARD=true | |
# Highlighting with command | |
zinit ice lucid wait='0' atinit='zpcompinit' | |
zinit light zdharma/fast-syntax-highlighting | |
# # Zsh-proxy | |
# zinit light sukkaw/zsh-proxy | |
# The FUCK plugin | |
zinit ice lucid wait='1' | |
zinit light laggardkernel/zsh-thefuck | |
# Z plugin | |
zinit ice lucid wait='1' | |
zinit light skywind3000/z.lua | |
# Enhance cd | |
zinit ice lucid wait='0' | |
zinit light "b4b4r07/enhancd" | |
# Auto suggestions | |
# zinit ice lucid wait="0" atload='_zsh_autosuggest_start' | |
# zinit light zsh-users/zsh-autosuggestions | |
# Oh My Zsh lib and plugins | |
zinit snippet OMZ::lib/completion.zsh | |
zinit snippet OMZ::lib/history.zsh | |
zinit snippet OMZ::lib/key-bindings.zsh | |
zinit snippet OMZ::lib/theme-and-appearance.zsh | |
zinit snippet OMZ::plugins/colored-man-pages/colored-man-pages.plugin.zsh | |
zinit snippet OMZ::plugins/sudo/sudo.plugin.zsh | |
zinit ice lucid wait='1' | |
zinit snippet OMZ::plugins/git/git.plugin.zsh | |
# Alias | |
alias rmrf="rm -rf" | |
alias gitcm="git commit -m" | |
alias gitp="git push" | |
alias gita="git add -a" | |
alias gitall="git add ." | |
alias git-undo="git reset --soft HEAD^" | |
alias ping="nali-ping" | |
alias dig="nali-dig" | |
alias traceroute="nali-traceroute" | |
alias tracepath="nali-tracepath" | |
alias nslookup="nali-nslookup" | |
alias digshort="nali-dig @223.6.6.6 +short " | |
alias ls='lsd' | |
alias l='ls -l' | |
alias la='ls -a' | |
alias lla='ls -la' | |
alias lt='ls --tree' | |
alias zc='z -c' | |
alias zz='z -i' | |
alias zf='z -I' | |
alias zb='z -b' | |
# alias python='python3' | |
# alias pip='pip3' | |
alias q="cd $HOME && clear" | |
# Avoid stupidity with trash-cli: | |
# https://github.com/sindresorhus/trash-cli | |
# or use default rm -i | |
if (( $+commands[trash] )); then | |
alias rm='trash' | |
else | |
alias rm='rm -i' | |
fi | |
# Hash | |
hash -d Desktop="$HOME/Desktop" | |
hash -d Music="$HOME/Music" | |
hash -d Pictures="$HOME/Pictures" | |
hash -d Picture="$HOME/Pictures" | |
hash -d Download="$HOME/Downloads" | |
hash -d Document="$HOME/Documents" | |
# hash -d Services="$HOME/Services" | |
# hash -d Project="$HOME/Projects" | |
hash -d Application="/Applications" | |
hash -d GitHub="$HOME/Documents/GitHub" | |
# Function | |
extract() { | |
if [[ -f $1 ]]; then | |
case $1 in | |
*.tar.bz2) tar xjf $1 ;; | |
*.tar.gz) tar xzf $1 ;; | |
*.bz2) bunzip2 $1 ;; | |
*.rar) unrar e $1 ;; | |
*.gz) gunzip $1 ;; | |
*.tar) tar xf $1 ;; | |
*.tbz2) tar xjf $1 ;; | |
*.tgz) tar xzf $1 ;; | |
*.zip) unzip "$1" ;; | |
*.Z) uncompress $1 ;; | |
*.7z) 7z x $1 ;; | |
*) echo "'$1' cannot be extracted via extract()" ;; | |
esac | |
else | |
echo "'$1' is not a valid file" | |
fi | |
} | |
brew-cask-upgrade() { | |
red=$(tput setaf 1) | |
# green=$(tput setaf 2) | |
reset=$(tput sgr0) | |
brew update | |
for cask in $(brew outdated --cask | awk '{print $1}'); do | |
echo "${red}update ${cask} ...${reset}." | |
brew install --cask --force "$cask" | |
done | |
echo "* ${red}brew clean up ...${reset}" | |
brew cleanup -s | |
echo "* ${red}brew clean up done.${reset}" | |
} | |
# Add OSX-like shadow to image | |
# USAGE: osx-shadow [--rm|-r] <original.png> [result.png] | |
osx-shadow() { | |
# Help message | |
function help { | |
echo "Wrong number of arguments have been entered." | |
echo "USAGE: osx-shadow [--rm|-r] <original.png> [result.png]" | |
} | |
if [[ $1 == --rm || $1 == -r ]]; then | |
# Remove shadow | |
case $# in | |
3) # osx-shadow --rm|-r src.png dist.png | |
convert $2 -crop +50+34 -crop -50-66 $3 | |
;; | |
2) # osx-shadow --rm|-r src.png | |
convert $2 -crop +50+34 -crop -50-66 ${2%.*}-croped.png | |
;; | |
*) | |
help | |
;; | |
esac | |
else | |
# Add shadow | |
case $# in | |
2) # osx-shadow src.png dist.png | |
convert $1 \( +clone -background gray -shadow 100x40+0+16 \) +swap -background none -layers merge +repage $2 | |
;; | |
1) # osx-shadow src.png | |
convert $1 \( +clone -background gray -shadow 100x40+0+16 \) +swap -background none -layers merge +repage ${1%.*}-shadow.png | |
;; | |
*) | |
help | |
;; | |
esac | |
fi | |
} | |
# Google tts audio | |
tts(){ | |
encode=$(python -c "import urllib, sys; print urllib.quote(sys.argv[1])" $1) | |
curl 'https://translate.google.cn/translate_tts?ie=UTF-8&q='$encode'&tl=zh-TW&client=tw-ob' -H 'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3835.0 Safari/537.36' -H 'referer: https://translate.google.cn/translate_tts?ie=UTF-8&q='$encode'&tl=zh-TW&client=tw-ob' 2>/dev/null > $1'.mp3' | |
} | |
# Git Delete Local Merged | |
git-delete-local-merged() { | |
red=$(tput setaf 1) | |
blue=$(tput setaf 4) | |
green=$(tput setaf 2) | |
reset=$(tput sgr0) | |
branches=($(git branch --merged master | grep -v "\*\|master\|unstable\|develop")) | |
[ -z "$branches" ] && printf "${green}\nNo merged branches to delete!${reset}\n" && exit; | |
command="git branch -d $branches" | |
echo "" | |
printf "%s" "$branches" | |
echo "" | |
printf "\n${blue}Delete merged branches locally? Press [Enter] to continue...${reset}" | |
read _ | |
echo "" | |
echo "Safely deleting merged local branches..." | |
for branch ($branches); do | |
git branch -d $branch | |
done | |
echo "${green}Done!${reset}" | |
} | |
# Man to PDF file | |
pdf() { | |
# Ventura 之前的系统 | |
# man -t $1 | open -fa Preview.app | |
# Ventura 及之后系统需安装 Ghostscript | |
man -t ls | ps2pdf - - | open -fa Preview | |
} | |
startEC() { | |
/Applications/EasyConnect.app/Contents/Resources/bin/EasyMonitor > /dev/null 2>&1 & | |
/Applications/EasyConnect.app/Contents/MacOS/EasyConnect > /dev/null 2>&1 & | |
} | |
fuckEC() { | |
function killprocess() | |
{ | |
processname=$1 | |
killall $processname >/dev/null 2>&1 | |
proxypids=$(ps aux | grep -v grep | grep $processname | awk '{print $2}') | |
for proxypid in $proxypids | |
do | |
kill -9 $proxypid | |
done | |
} | |
killprocess svpnservice | |
killprocess CSClient | |
killprocess ECAgentProxy | |
killprocess /Applications/EasyConnect.app/Contents/MacOS/EasyConnect | |
pkill ECAgent | |
pkill EasyMonitor | |
} | |
# StarShip | |
eval "$(starship init zsh)" | |
# pnpm | |
export PNPM_HOME="/Users/lufsx/Library/pnpm" | |
export PATH="$PNPM_HOME:$PATH" | |
# pnpm end | |
# pyenv | |
export PYENV_ROOT="$HOME/.pyenv" | |
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH" | |
eval "$(pyenv init -)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment