From b5ee45735918f487fcb4d74f6df63710dab1cd00 Mon Sep 17 00:00:00 2001 From: evlic Date: Mon, 11 Sep 2023 12:45:23 +0800 Subject: [PATCH] fix: ohm --- Makefile | 4 +++- install-oh-my-zsh.sh | 12 ++++++++++- install-p10k.sh | 50 ++++---------------------------------------- 3 files changed, 18 insertions(+), 48 deletions(-) mode change 100644 => 100755 install-oh-my-zsh.sh diff --git a/Makefile b/Makefile index 088f36d..986ec52 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,8 @@ install: -ohm: ./install-zsh.sh +ohm: + chmod +x $(OS) + $(OS) alias: chmod +x $(AS) && $(AS) \ No newline at end of file diff --git a/install-oh-my-zsh.sh b/install-oh-my-zsh.sh old mode 100644 new mode 100755 index b014fd9..a92a09b --- a/install-oh-my-zsh.sh +++ b/install-oh-my-zsh.sh @@ -509,4 +509,14 @@ EOF if [ $RUNZSH = no ]; then echo "${FMT_YELLOW}Run zsh to try it out.${FMT_RESET}" exit - fi \ No newline at end of file + fi + + git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k + + cp ~/.zshrc ~/.zshrc.ohm.bak + awk '{gsub(/ZSH_THEME="robbyrussell"/, "ZSH_THEME=\"powerlevel10k/powerlevel10k\""); print}' ~/.zshrc > temp && mv temp ~/.zshrc + echo 'auto apply $ZSH_THEME="powerlevel10k/powerlevel10k"' + exec zsh -l +} + +main "$@" \ No newline at end of file diff --git a/install-p10k.sh b/install-p10k.sh index a8aa162..6a2e4a9 100644 --- a/install-p10k.sh +++ b/install-p10k.sh @@ -512,53 +512,11 @@ EOF fi git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k - - sed -i 's/ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"powerlevel10k\/powerlevel10k\"/g' ~/.zshrc + # sed -i 's/ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"powerlevel10k\/powerlevel10k\"/g' ~/.zshrc + cp ~/.zshrc ~/.zshrc.ohm.bak + awk '{gsub(/ZSH_THEME="robbyrussell"/, "ZSH_THEME=\"powerlevel10k/powerlevel10k\""); print}' ~/.zshrc > temp && mv temp ~/.zshrc echo 'apply $ZSH_THEME="powerlevel10k/powerlevel10k"' - - if [ ! -f "~/.alias.d" ];then - echo "将创建 ~/.alias.d 用于存放自定义快捷方式" - AHome="$HOME/.alias.d" - mkdir "$AHome" - init_sell="$AHome/.init" - 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" - else - echo ".alias 已存在,将不做改动" - fi - - echo "source "$init_shell"" >> ~/.zshrc - exec zsh -l + zsh } main "$@" \ No newline at end of file