From 7eb3f28931507382c2ac2b9445b6897cc539af4a Mon Sep 17 00:00:00 2001 From: simon Date: Tue, 19 Apr 2022 18:12:28 +0700 Subject: [PATCH] add zshrc --- .zshrc | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 .zshrc diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..82fc4c8 --- /dev/null +++ b/.zshrc @@ -0,0 +1,93 @@ +# 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 + +# some envs +HISTFILE=~/.histfile +HISTSIZE=2000 +SAVEHIST=2000 +export PATH=$HOME/bin:/usr/local/bin:/sbin:/usr/sbin:$PATH +export EDITOR="vim" +export PAGER="less" +export LESS_TERMCAP_mb=$'\e[1;32m' +export LESS_TERMCAP_md=$'\e[1;32m' +export LESS_TERMCAP_me=$'\e[0m' +export LESS_TERMCAP_se=$'\e[0m' +export LESS_TERMCAP_so=$'\e[01;35m' +export LESS_TERMCAP_ue=$'\e[0m' +export LESS_TERMCAP_us=$'\e[1;4;34m' + +# customs +setopt appendhistory autocd extendedglob nomatch notify +unsetopt beep +bindkey -v +zstyle :compinstall filename '/home/simon/.zshrc' +zstyle ':completion:*' menu select +setopt COMPLETE_ALIASES +autoload -Uz compinit promptinit +compinit +promptinit + +# change text color based on hostname (256 colors) +if [[ "$HOST" == arch ]]; then + text='243' # light gray +elif [[ "$HOST" == pi ]]; then + text='124' # dark red +elif [[ "$HOST" == blackhole ]]; then + text='28' # dark green +elif [[ "$HOST" =~ fra1 ]]; then + text='3' # dark yellow +else + text='246' # gray +fi +# change prompt color of '$|%' based on euid +if [[ $EUID -eq 0 ]]; then + prompt='160' # light read +else + prompt='27' # dark blue +fi + +PS1="[%F{"$text"}%n@%m%f %1~%f]%(?..%F{124} ●) %F{"$prompt"}%%%f " + +# sourcing things +if [[ -f .zsh_aliases ]]; then + source .zsh_aliases +fi + +if [[ -f .zsh_aliases_extra ]]; then + source .zsh_aliases_extra +fi + +if [[ -f .zsh_functions ]]; then + source .zsh_functions +fi + +if [[ -f .zsh_functions_extra ]]; then + source .zsh_functions_extra +fi + +if [ -f ~/script/login.sh ]; then + /bin/bash $HOME/script/login.sh +fi + +# plugins +if [ -f /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then + source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh +fi + +# key bindings +bindkey "${terminfo[khome]}" beginning-of-line +bindkey "${terminfo[kend]}" end-of-line + +# attach to tmux or create main +if [[ -z "$TMUX" ]] && [ "$SSH_CONNECTION" != "" ]; then + TERM=xterm + tmux new-session -A -s main +fi +source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme + +# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. +[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh