From 4ed23ee299b1bfd193ab293dc1ec55eda515db99 Mon Sep 17 00:00:00 2001 From: major Date: Sun, 25 Jun 2023 13:32:44 +0800 Subject: [PATCH] optimize usage --- .gitignore | 2 +- .gitmodules | 9 ++++++++ templates/zshrc.zsh-template | 40 +++++++++++++++++++++++++++++++++--- tools/install.sh | 5 +++-- 4 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 .gitmodules diff --git a/.gitignore b/.gitignore index 10bd4bebc..d9302465a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # custom files -custom/ +# custom/ # temp files directories cache/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..3c847cb3d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,9 @@ +[submodule "custom/plugins/zsh-autosuggestions"] + path = custom/plugins/zsh-autosuggestions + url = https://github.com/zsh-users/zsh-autosuggestions.git +[submodule "custom/plugins/zsh-syntax-highlighting"] + path = custom/plugins/zsh-syntax-highlighting + url = https://github.com/zsh-users/zsh-syntax-highlighting.git +[submodule "custom/themes/powerlevel10k"] + path = custom/themes/powerlevel10k + url = https://gitee.com/romkatv/powerlevel10k.git diff --git a/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index 7e1c7997c..2d1d1c529 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -1,14 +1,21 @@ +# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc. +# Initialization code that may require console input (password prompts, [y/n] +# confirmations, etc.) must go above this block; everything else may go below. +if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then + source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" +fi + # If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/usr/local/bin:$PATH # Path to your oh-my-zsh installation. -export ZSH=$HOME/.oh-my-zsh +export ZSH="$HOME/.oh-my-zsh" # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes -ZSH_THEME="robbyrussell" +ZSH_THEME="powerlevel10k/powerlevel10k" # Set list of themes to pick from when loading at random # Setting this variable when ZSH_THEME=random will cause zsh to load @@ -70,7 +77,17 @@ ZSH_THEME="robbyrussell" # Custom plugins may be added to $ZSH_CUSTOM/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. -plugins=(git) +plugins=( + git + autojump + zsh-autosuggestions + zsh-syntax-highlighting + tmux +) + +# In general, all the ZSH_* variables for controlling oh-my-zsh behavior +# need to be set before initializing oh-my-zsh. +ZSH_TMUX_AUTOSTART=true source $ZSH/oh-my-zsh.sh @@ -99,3 +116,20 @@ source $ZSH/oh-my-zsh.sh # Example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" + +# Set/Unset proxy aliases +HOSTIP=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*') +alias setp='export https_proxy="http://${HOSTIP}:7890"; export http_proxy="http://${HOSTIP}:7890"; export all_proxy="socks5://${HOSTIP}:7890"; export ALL_PROXY="socks5://${HOSTIP}:7890";' +alias unsetp='unset https_proxy; unset http_proxy; unset all_proxy; unset ALL_PROXY;' + +# Fzf +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh +export FZF_DEFAULT_COMMAND='ag -i --hidden -l -g ""' +export FZF_DEFAULT_OPTS="--layout=reverse --preview '(bat --style=numbers --color=always {} || highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'" +export PATH=$PATH:$HOME/.fzf/bin + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh + +# inhibit p10k warning +typeset -g POWERLEVEL9K_INSTANT_PROMPT=quiet diff --git a/tools/install.sh b/tools/install.sh index ac756e093..c885e7dfc 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -360,8 +360,9 @@ setup_zshrc() { fi omz=$(echo "$omz" | sed "s|^$HOME/|\$HOME/|") - sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp" - mv -f "$zdot/.zshrc-omztemp" "$zdot/.zshrc" + # sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp" + # mv -f "$zdot/.zshrc-omztemp" "$zdot/.zshrc" + ln -sf "$ZSH/templates/zshrc.zsh-template" "$zdot/.zshrc" echo }