From 72eb9d6c728430834c0c2e51cde28633756cc0d7 Mon Sep 17 00:00:00 2001 From: Renge Date: Mon, 3 Jan 2022 00:47:53 -0500 Subject: [PATCH] feat: add zsh config files and setup script --- README.md | 1 + setup.sh | 34 ++++++++++++++++++++++++++++++++++ zshrc | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+) create mode 100644 README.md create mode 100755 setup.sh create mode 100644 zshrc diff --git a/README.md b/README.md new file mode 100644 index 0000000..4640904 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# TODO diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..d7085ec --- /dev/null +++ b/setup.sh @@ -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 ---------------- diff --git a/zshrc b/zshrc new file mode 100644 index 0000000..375cb93 --- /dev/null +++ b/zshrc @@ -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