# shellcheck shell=ksh AHome="$HOME/alias.d" if [ ! -f "$AHome" ];then echo "将创建 ~/.alias.d 用于存放自定义快捷方式" mkdir "$AHome" fi init_shell="$AHome/.init" echo alias in "$AHome" echo "" > "$init_shell" echo '# set PATH so it includes user`s private bin if it exists' >> "$init_shell" echo 'if [ -d "$HOME/bin" ] ; then' >> "$init_shell" echo ' PATH="$HOME/bin:$PATH"' >> "$init_shell" echo 'fi' >> "$init_shell" echo '' >> "$init_shell" echo '# set PATH so it includes user`s private bin if it exists' >> "$init_shell" echo 'if [ -d "$HOME/.local/bin" ] ; then' >> "$init_shell" echo ' PATH="$HOME/.local/bin:$PATH"' >> "$init_shell" echo 'fi' >> "$init_shell" echo '' >> "$init_shell" echo '# set PATH so it includes user`s private bin if it exists' >> "$init_shell" echo 'if [ -d "$HOME/go/bin" ] ; then' >> "$init_shell" echo ' PATH="$HOME/go/bin:$PATH"' >> "$init_shell" echo 'fi' >> "$init_shell" echo "setopt no_nomatch" >> "$init_shell" echo '# 遍历' >> "$init_shell" echo '# for item in `ls ~/.alias.d/*.sh`; do' >> "$init_shell" echo '# source $item' >> "$init_shell" echo '# done' >> "$init_shell" echo 'export AHome="$HOME"/.alias.d' >> "$init_shell" echo 'for ali in "$AHome"/*.sh' >> "$init_shell" echo 'do' >> "$init_shell" echo ' [[ -e "$ali" ]] || break # 无 alias 停止' >> "$init_shell" echo ' source "$ali"' >> "$init_shell" echo 'done' >> "$init_shell" echo "#common config" >> "$init_shell" echo "alias va='vim ~/.alias.d'" >> "$init_shell" echo "alias vz='vim ~/.zshrc'" >> "$init_shell" echo "alias rez='source ~/.zshrc'" >> "$init_shell" echo "source "$init_shell"" >> ~/.zshrc