feat: add zsh config files and setup script

This commit is contained in:
Renge 2022-01-03 00:47:53 -05:00
commit 72eb9d6c72
3 changed files with 81 additions and 0 deletions

1
README.md Normal file
View File

@ -0,0 +1 @@
# TODO

34
setup.sh Executable file
View File

@ -0,0 +1,34 @@
# /bin/sh
verify () {
yesexpr="^[yY1+是]|^\s*$"
while true; do
read -p "$1" yn
if [[ "$yn" =~ $yesexpr ]]; then
return 1
else
return 0
fi
done
}
# ---------------- zshrc start ----------------
echo "setting up zsh"
if [ -e ~/.zshrc ]
then
echo "~/.zshrc exists, backup to ./zshrc_backup"
mv ~/.zshrc ./zshrc_backup
fi
ln ./zshrc ~/.zshrc
# comment the following line if not running on arch-based linux
verify "Are you running on arch-based linux? (Y/n)"
if [[ $? == 1 ]]
then
sudo pacman -Syu zsh-syntax-highlighting
else
echo -e "\e[1;31mPlease find zsh-syntax-highlighting https://github.com/zsh-users/zsh-syntax-highlighting suitable for your distro\e[0m"
fi
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions
git clone https://github.com/qndydyhm/zsh-ssh ~/.zsh/zsh-ssh
# ---------------- zshrc end ----------------

46
zshrc Normal file
View File

@ -0,0 +1,46 @@
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
bindkey -v
# End of lines configured by zsh-newuser-install
# The following lines were added by compinstall
zstyle :compinstall filename '~/.zshrc'
autoload -Uz compinit
compinit
# End of lines added by compinstall
setopt HIST_IGNORE_DUPS
PROMPT='%F{#f0c0e0}%n%f@%F{#c0f0e0}%m%f %F{#c0e0f0}%B%~%b%f %# '
RPROMPT='[%F{yellow}%?%f]'
# Auto refresh package name
zstyle ':completion:*' rehash true
# Syntax highlight (need zsh-syntax-highlighting package)
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# Auto suggestion https://github.com/zsh-users/zsh-autosuggestions
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh
# SSH auto completion https://github.com/qndydyhm/zsh-ssh
source ~/.zsh/zsh-ssh/zsh-ssh.zsh
# History search
autoload -U history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^[[A" history-beginning-search-backward-end
bindkey "^[[B" history-beginning-search-forward-end
alias ls='ls --color=always'
alias ll='ls --color=always -lh'
alias ra='ranger'
alias open='xdg-open'
alias vimf='vim "$(fzf --height 40%)"'
#
zstyle ':completion:*:(ssh|scp|ftp|sftp):*' hosts $hosts
zstyle ':completion:*:(ssh|scp|ftp|sftp):*' users $users