optimize usage

This commit is contained in:
major 2023-06-25 13:32:44 +08:00
commit 4ed23ee299
4 changed files with 50 additions and 6 deletions

2
.gitignore vendored
View file

@ -1,5 +1,5 @@
# custom files
custom/
# custom/
# temp files directories
cache/

9
.gitmodules vendored Normal file
View file

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

View file

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

View file

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