Created
November 23, 2020 13:19
-
-
Save YiPrograms/df9f96bac795f5905c522cbb459f3a29 to your computer and use it in GitHub Desktop.
.zshrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Powerlevel10k instant prompt (Prompt will flash on start) | |
# 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 | |
## zsh-newuser-install | |
HISTFILE=~/.histfile | |
HISTSIZE=1000 | |
SAVEHIST=1000 | |
setopt HIST_IGNORE_ALL_DUPS | |
## Exports | |
export PYENV_ROOT="$HOME/.pyenv" | |
export PATH="$PYENV_ROOT/bin:$PYENV_ROOT/shims:$PATH" | |
export PATH="/home/yi/.rbenv/shims:${PATH}" | |
export RBENV_SHELL=zsh | |
zstyle ':completion:*' menu select | |
## Sources | |
source /usr/share/doc/pkgfile/command-not-found.zsh | |
source /usr/share/zsh/site-functions/_pyenv | |
source ~/.zkbd/xterm-256color | |
## Aliases | |
alias ls='ls --color=auto' | |
alias vim='nvim' | |
alias clip='xclip -sel clip' | |
alias wifi='nmcli dev wifi' | |
alias nas='restic -r sftp:DreamNAS:/share/CACHEDEV1_DATA/Backup/Yi/Backup --verbose' | |
## Functions | |
# systemd completion fix | |
_systemctl_unit_state() { | |
typeset -gA _sys_unit_state | |
_sys_unit_state=( $(__systemctl list-unit-files "$PREFIX*" | awk '{print $1, $2}') ) | |
} | |
# pyenv | |
pyenv() { | |
echo "Pyenv is not loaded! Loading now..." | |
unset -f pyenv | |
eval "$(pyenv init - --no-rehash)" | |
eval "$(pyenv virtualenv-init -)" | |
pyenv "$@" | |
} | |
nvm() { | |
echo "nvm is not loaded! Loading now..." | |
unset -f nvm | |
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm" | |
source /usr/share/nvm/nvm.sh | |
source /usr/share/nvm/bash_completion | |
source /usr/share/nvm/install-nvm-exec | |
nvm "$@" | |
} | |
rbenv() { | |
echo "rbenv is not loaded! Loading now..." | |
unset -f rbenv | |
eval "$(rbenv init -)" | |
rbenv "$@" | |
} | |
# C++ complie functions | |
c() { # Compile | |
if [[ -n "$1" ]] | |
then | |
cf="${1%.*}" | |
fi | |
echo "\n===Compiling [$cf.cpp]===" | |
g++ -std=c++11 -O2 -fsanitize=undefined -Wall -Wextra -Wshadow -o "$cf.o" "$cf.cpp" | |
echo "===Compile Finished===" | |
} | |
x() { # Run | |
if [[ -n "$1" ]] | |
then | |
cf="${1%.*}" | |
fi | |
if [ -f "$cf.i" ] | |
then | |
echo "\n===Running [$cf.o] < [$cf.i]===" | |
./$cf.o < $cf.i | |
else | |
echo "\n===Running [$cf.o]===" | |
./$cf.o | |
fi | |
} | |
cx() { # Compile & Run | |
c $1 | |
x $1 | |
} | |
### Added by Zinit's installer | |
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then | |
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f" | |
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit" | |
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \ | |
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \ | |
print -P "%F{160}▓▒░ The clone has failed.%f%b" | |
fi | |
source "$HOME/.zinit/bin/zinit.zsh" | |
autoload -Uz _zinit | |
(( ${+_comps} )) && _comps[zinit]=_zinit | |
# Load a few important annexes, without Turbo | |
# (this is currently required for annexes) | |
zinit light-mode for \ | |
zinit-zsh/z-a-patch-dl \ | |
zinit-zsh/z-a-as-monitor \ | |
zinit-zsh/z-a-bin-gem-node | |
### End of Zinit's installer chunk | |
## Plugins | |
zinit wait lucid light-mode for \ | |
zsh-users/zsh-autosuggestions \ | |
zdharma/fast-syntax-highlighting \ | |
zdharma/history-search-multi-word \ | |
atload"zicompinit; zicdreplay" blockf \ | |
zsh-users/zsh-completions \ | |
zdharma/history-search-multi-word \ | |
chrissicool/zsh-256color \ | |
paulirish/git-open \ | |
hlissner/zsh-autopair \ | |
arzzen/calc.plugin.zsh \ | |
OMZL::git.zsh \ | |
OMZP::colored-man-pages \ | |
atload"unalias grv" \ | |
OMZP::git \ | |
as"completion" \ | |
OMZP::docker/_docker \ | |
OMZP::sudo \ | |
OMZP::autojump \ | |
# Powerlevel10k | |
zinit ice lucid depth=1 | |
zinit light romkatv/powerlevel10k | |
__zinit_async_run () { | |
} | |
# Run commands in __zinit_async_run asynchronously | |
zinit ice wait lucid atload'__zinit_async_run' | |
zinit light null | |
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. | |
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment