feat: add pre set environment variables

This commit is contained in:
🐟 2023-09-13 16:57:38 +08:00
parent 0abefb4054
commit 08ab7704c1
5 changed files with 101 additions and 0 deletions

1
.gitignore vendored
View File

@ -3,4 +3,5 @@
_* _*
!.gitignore !.gitignore
!.init
data data

21
alias.d/.init Executable file
View File

@ -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

23
alias.d/dev.sh Executable file
View File

@ -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
###

18
alias.d/docker.sh Executable file
View File

@ -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'

38
alias.d/pkg.sh Normal file
View File

@ -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"
}