-
Notifications
You must be signed in to change notification settings - Fork 2
/
custom_alias.zsh
148 lines (121 loc) · 4.25 KB
/
custom_alias.zsh
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
# !!! rm 像魔鬼一样刺激我的多巴胺, 尽管它能带给我快感, 但我还是要抵制它 !!!
# alias rm="echo Use 'rmm', or the full path i.e. '/bin/rm'"
function rm() {
# https://iboysoft.com/questions/why-is-there-no-put-back-button-in-mac-trash.html
echo -e '\033[31mUse "rmm", or the full path i.e. "/bin/rm"\033[0m'
if ! command -v trash &> /dev/null; then
echo -e '\033[31mtrash command not found. Please install trash first.\033[0m'
return
fi
trash "$@"
}
alias rmm="trash" # brew install trash
# -------------------------------- #
# Application alias
# -------------------------------- #
# https://stackoverflow.com/a/19663203/11302760
alias st='open -a SourceTree .'
alias f="open_fork"
alias fk="caffeinate -u -t 3600" # prevent mac from sleeping
# -------------------------------- #
# Directory alias
# -------------------------------- #
alias w="cd $WORKSPACE"
alias com="cd $COMPANY"
# alias stu="cd $STUDY"
alias oss="cd $OSS"
alias my="cd $MY"
alias play="cd $PLAY"
alias con="cd $CONFIG"
alias scr="cd $SCRIPTS"
# -------------------------------- #
# Node Package Manager
# dependent on https://github.com/wxh16144/ni
# -------------------------------- #
alias i="ni"
alias io="ni --prefer-offline"
alias rei="re-install-fe-deps"
# alias s="nr start"
alias s="start_fe_project"
# alias b="nr build"
alias b="compile_fe_peoject"
alias t="nr test"
alias tw="nr test --watch"
alias tu="nr test -u"
alias lint="nr lint"
alias lintf="nr lint --fix"
alias release="npx release-it"
alias nrr="npm_registry_manage" # npm registry manage
# -------------------------------- #
# Command Line Tools
# -------------------------------- #
alias o="open ."
alias p="pwd"
alias e="exit"
alias h='history'
alias cpwd="pwd | pbcopy && echo successfully"
alias big='du -s ./* | sort -nr | awk '\''{print $2}'\'' | xargs du -sh'
alias cl='count_lines'
alias project='quick_start_project'
# https://ollama.com/
alias ai="ollama"
# alias killai="pgrep -f ollama | xargs kill -9"
# https://askubuntu.com/a/473770
alias c="clear && printf '\e[3J'"
# where tree
alias tree="/opt/homebrew/bin/tree -I 'node_modules|cache|test_*' -L 3"
# hide a directory or file
alias hide="chflags hidden"
alias show="chflags nohidden"
# https://stackoverflow.com/a/71716482
alias hideicon="defaults write com.apple.finder CreateDesktop -bool false && killall Finder"
alias showicon="defaults write com.apple.finder CreateDesktop -bool true && killall Finder"
# front-end-node_modules
alias lsnm="list_node_modules"
alias rmnm="remove_node_modules"
# nvm install
alias nvmi="nvm_install"
alias del="remove_all_files"
alias dir="create_and_cd"
alias dirt="create_tmp_dir"
# network
alias ip="get_ip"
alias ipl="get_ip_local"
alias ser="quick_server"
alias pser="private_server"
alias port="list_common_ports" # 列举一些常用的端口占用情况
alias portkill="kill_port" # 杀掉指定端口的进程
# zsh
alias zshrc='code --disable-extensions "${ZDOTDIR:-$HOME}"/.zshrc'
alias reload='source "${ZDOTDIR:-$HOME}"/.zshrc'
alias custom="code --disable-extensions $ZSH_CUSTOM"
# -------------------------------- #
# Git shortcut
# -------------------------------- #
alias clone="clone_and_cd"
alias clonet="clone_to_tmp_dir"
alias clonemy="clone_my_project"
alias cloneoss="clone_oss_project"
# clone https://github.com/react-component/xxx.git
alias cloneossrc="clone_oss_org_project react-component"
alias rc="cd $OSS/react-component"
# clone https://github.com/umijs/xxx.git
alias cloneossumijs="clone_oss_org_project umijs"
# clonse https://github.com/ant-design/xxx.git
alias cloneossant="clone_oss_org_project ant-design"
# 切换到指定分支(默认主分支)拉取更新后,再切回来
alias gbsw="git_branch_pull_switch"
# 快速修复某一条记录(默认上一条),并进行 rebase squash 操作
alias gfix="git_fixup_commit"
# 使用一个分支备份当前 git 修改
alias gbp="git_create_branch_backup"
# 批量删除分支, 支持 grep 参数,输入 y 确定删除
alias gbdel="git_batch_delete_branch"
# 列举本地常见的分支的 hash
alias gblhash="list_local_branch_hash"
# 解析 url 并添加 git remote
alias gae="git_add_remote"
# 将指定目录推送到远程仓库
alias pudir="push_ignored_directory"
# 覆盖 antd 依赖,仅支持 rc-xxx 依赖
alias oad="override-antd-deps"