diff --git a/.gitignore b/.gitignore index 734e6da..dee74a8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ _* !.gitignore +!.init data \ No newline at end of file diff --git a/alias.d/.init b/alias.d/.init new file mode 100755 index 0000000..ae0366d --- /dev/null +++ b/alias.d/.init @@ -0,0 +1,21 @@ +#!env zsh +# shellcheck shell=ksh + + +# 解决 zsh 一些指令错误匹配的问题 +setopt no_nomatch + +# 遍历 +# for item in `ls ~/alias.d/*.sh`; do +# source $item +# done +export AHome="$HOME"/alias.d +for ali in "$AHome"/*.sh +do + [[ -e "$ali" ]] || break # 无 alias 停止 + source "$ali" +done + +# 等价于⬇️ +# source ~/alias.d/dev.sh +# source ~/alias.d/docker.sh \ No newline at end of file diff --git a/alias.d/dev.sh b/alias.d/dev.sh new file mode 100755 index 0000000..4f7e4b8 --- /dev/null +++ b/alias.d/dev.sh @@ -0,0 +1,23 @@ +# shellcheck shell=ksh + +### +# pnpm +### +export PNPM_HOME="$HOME/Library/pnpm" +export PATH="$PNPM_HOME:$PATH" +### + + +### +# nvm +### +export NVM_DIR="$HOME/.nvm" +[ -s "/usr/local/opt/nvm/nvm.sh" ] && \. "/usr/local/opt/nvm/nvm.sh" # This loads nvm +[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion +### + +### +# java +### +export JAVA_HOME=/Applications/Jetbrains/GoLand.app/Contents/jbr/Contents/Home +### \ No newline at end of file diff --git a/alias.d/docker.sh b/alias.d/docker.sh new file mode 100755 index 0000000..6892302 --- /dev/null +++ b/alias.d/docker.sh @@ -0,0 +1,18 @@ +# shellcheck shell=ksh + +# docker 快捷指令 +# alias docker='_ docker' +alias dc='docker container' +alias di='docker image' +alias dcl='dc logs -f -n 100 ' +alias dcrun='docker exec -it ' +alias dtmp='docker run -it --rm' + +alias dp='docker compose' +alias dpup='dp up -d --force-recreate' + +alias ds='docker ps -a --format "table{{.Names}}\t{{.Status}}"' +alias dsp='docker ps -a --format "table{{.Names}}\t{{.Status}}\t{{.Ports}}"' + +alias dps='dp ps -a' +alias dcp='docker cp' \ No newline at end of file diff --git a/alias.d/pkg.sh b/alias.d/pkg.sh new file mode 100644 index 0000000..f32104b --- /dev/null +++ b/alias.d/pkg.sh @@ -0,0 +1,38 @@ +# shellcheck shell=ksh + +# 本机包管理器快捷方式 +alias pkg="brew" +alias sea="pkg search " +alias ins="pkg install -y " +alias ser='pkg services' + +# pm2 守护线程 +alias pmstart='pm2 start ' +alias pmdown='pm2 del ' +alias pmstop='pm2 stop ' + +alias pmr='pm2 restart ' +alias pml='pm2 log --lines 100 ' + +# 重启 pm2 服务配置 +alias pmrr='pm2 resurrect' + +pmup() { + _worker_name=$1 + pms "$_worker_name" && pml "$_worker_name" +} + +pmrun() { + _cmd=$1 + _name=$2 + if [ -n "$_name" ]; then + pmst -x "$_cmd" --name "$_name" + else + pmst -x "$_cmd" + fi +} + +pms() { + _worker_name=$1 + pmr "$_worker_name" && pml "$_worker_name" +} \ No newline at end of file