-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathaliases.sh
More file actions
152 lines (137 loc) · 4.74 KB
/
Copy pathaliases.sh
File metadata and controls
152 lines (137 loc) · 4.74 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
export GREP_COLORS='mt=1;31'
export LC_ALL="zh_CN.UTF-8"
# export LESS='-NRF'
# export LESSOPEN='| pygmentize -g -O style=native %s'
[[ ! ":${PATH}:" =~ "/usr/local/sbin" ]] && export PATH="/usr/local/sbin:$PATH"
[[ ! ":${PATH}:" =~ "$HOME/.local/bin" ]] && export PATH="$HOME/.local/bin:$PATH"
[[ ! ":${PATH}:" =~ "$HOME/.local/utils" ]] && export PATH="$HOME/.local/utils:$PATH"
# Custom alias
alias l='ls -ClhoF'
alias li='ls -Clhoi'
alias ll='ls -ClhF'
alias la='ls -A'
alias lla='ls -ClhFA'
alias rm='rm -v'
alias cp='cp -nv'
alias mv='mv -nv'
alias ln='ln -v'
alias cls='clear'
alias rs="rsync -crvzptHP --exclude='.[A-Za-z0-9._-]*' --exclude={__pycache__,'*.pyc'}"
alias grep="grep -I --color=auto --exclude-dir='.[A-Za-z0-9._-]*' --exclude-dir=node_modules --exclude-dir=.venv"
alias psgrep='pscm|grep -v grep|grep'
alias tree='tree -N -C --dirsfirst -I "__pycache__|*.pyc|*.pyo|node_modules|dist|build|target|vendor"'
# alias less='less -N'
alias aria='aria2c -c -x 16 --file-allocation=none'
alias axel='axel -n 30'
alias myip='curl -Ls http://seamile.cn/myip'
alias ping='pingx -i 0.05 -c 10'
alias sping='/sbin/ping -i 0.05'
alias ip4="ifconfig | grep -w inet | awk '{print \$2}'| sort"
alias ip6="ifconfig | grep -w inet6 | awk '{print \$2}'| sort"
alias tailf='tail -F'
alias tm='tmux attach || tmux'
alias yz='yazi'
alias yt='yt-dlp --extractor-args "youtube:player_client=android" --js-runtimes node'
# macOS alias
if [ `uname` = "Darwin" ]; then
export HOMEBREW_NO_AUTO_UPDATE=true # disable homebrew auto update
# export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
# export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
export HOMEBREW_NO_INSTALL_CLEANUP=1
alias showfiles="defaults write com.apple.finder AppleShowAllFiles -bool true && killall Finder"
alias hidefiles="defaults write com.apple.finder AppleShowAllFiles -bool false && killall Finder"
alias lock="sudo chflags schg"
alias unlock="sudo chflags noschg"
fi
# Python alias
alias py='python'
alias ipy='ipython'
alias httpserver='python -m http.server'
alias pip-search='pip_search'
alias rmpyc='find . | grep -wE "py[co]|__pycache__" | xargs rm -rvf'
alias pygrep='grep --include="*.py"'
alias pip='uv pip'
alias venv='uv venv'
alias upy='uv python'
# Git alias
alias gad='git add'
alias gst='git status -sb'
alias gdf='git difftool'
alias glg='git log --stat --graph --max-count=10'
alias gpl='git pull'
alias gci='git commit'
alias gco='git checkout'
alias gsw='git switch'
alias gmg='git merge --no-commit --squash'
# brew
if has_cmd brew; then
# BREWHOME=`brew --prefix`
BREWHOME="/usr/local"
export LDFLAGS="-L$BREWHOME/lib"
export CPPFLAGS="-I$BREWHOME/include"
export PKG_CONFIG_PATH="$BREWHOME/lib/pkgconfig"
fi
# Rust env
if [[ -d $HOME/.cargo && ! ":${PATH}:" =~ "$HOME/.cargo/bin" ]]; then
export PATH="$HOME/.cargo/bin:$PATH"
fi
# Golang env
if has_cmd go; then
export GOPATH="$HOME/src/Golang"
export PATH="$GOPATH/bin:$PATH"
export GOPROXY="https://goproxy.cn"
fi
# Flutter
if has_cmd flutter; then
# Flutter src dir
export FLUTTER_ROOT="$HOME/.local/flutter"
export FLUTTER_SRC="$FLUTTER_ROOT/packages/flutter/lib/src"
# Flutter CN mirror
export PUB_HOSTED_URL='https://pub.flutter-io.cn'
export FLUTTER_STORAGE_BASE_URL='https://storage.flutter-io.cn'
fi
# Podman
if has_cmd podman; then
alias docker="podman"
alias docker-compose="podman-compose"
export PODMAN_COMPOSE_WARNING_LOGS=false
fi
# Nvm
if [ -d $HOME/.nvm ]; then
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
fi
# Bun
if [ -d $HOME/.bun/bin ]; then
# bun
export BUN_INSTALL="$HOME/.bun"
export PATH="$BUN_INSTALL/bin:$PATH"
# bun completions
[[ "$0" == *zsh && -s "$HOME/.bun/_bun" ]] && source "$HOME/.bun/_bun"
fi
# pnpm
if [ -d $HOME/.local/share/pnpm ]; then
export PNPM_HOME="$HOME/.local/share/pnpm"
export PATH="$PNPM_HOME:$PATH"
$PNPM_HOME/pnpm config set global-bin-dir $HOME/.local/bin
alias npm='pnpm'
alias npx='pnpx'
fi
# openspec
if [[ "$0" == *zsh ]] && has_cmd openspec; then
fpath=("$HOME/.oh-my-zsh/custom/completions" $fpath)
autoload -Uz compinit
compinit
fi
# SoftClear for Ghostty
if [[ $0 == *zsh && "$TERM_PROGRAM" == "ghostty" ]]; then
soft_clear() {
printf '\n%.0s' {1..$LINES} # 把内容推出视野
printf '\033[H' # 光标回左上角(不清屏)
zle reset-prompt # 重绘提示符
}
zle -N soft_clear
bindkey '^L' soft_clear
fi