From e893a0a0fa20f5884eab19850cf982b896a28cba Mon Sep 17 00:00:00 2001 From: Taylor Bockman Date: Sun, 31 Jul 2022 10:49:22 -0700 Subject: [PATCH] Add zsh syntax highlighting with version checks --- README.md | 6 +++++- dotfiles/zsh/zshrc | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 79d2c79..fb476ae 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,11 @@ The directory structure is as follows: ## Terminal I am back to `zsh` after a long time with `bash`. See the `dotfiles/zsh` directory. You only need to -symlink `.zprofile` and `.zshrc` to your home directory. +symlink `.zprofile` and `.zshrc` to your home directory. Refer to the `README.md` in the directory +for more information. + +My `.zshrc` installs a lot of nice conveniences. For example, fish-shell-like syntax highlighting and +git completion. ## Vim diff --git a/dotfiles/zsh/zshrc b/dotfiles/zsh/zshrc index 7dc43d8..e46656f 100644 --- a/dotfiles/zsh/zshrc +++ b/dotfiles/zsh/zshrc @@ -7,8 +7,6 @@ else symlink_dir=$(cd "$( dirname "`readlink ${(%):-%N}`" )" && pwd) fi -# -------------------------------- SETUP -------------------------------- # - # Store private information (exports, keys, etc) in .bash_private. if [[ -f $HOME/.bash_private ]]; then source $HOME/.bash_private @@ -62,13 +60,18 @@ fi # Install zsh-syntax-highlighting if it doesn't exist if [[ ! -d $HOME/.zsh/zsh-syntax-highlighting ]]; then - echo "Installing zsh syntax highlighting" - pushd - - cd $HOME/.zsh - git clone https://github.com/zsh-users/zsh-syntax-highlighting.git + if ! is-at-least 4.3.11; then + echo "ZSH syntax highlighting requires ZSH >= 4.3.11 (current: $ZSH_VERSION)." + else + echo "Installing zsh syntax highlighting" + pushd + + cd $HOME/.zsh + git clone https://github.com/zsh-users/zsh-syntax-highlighting.git + + popd + fi - popd fi zstyle ':completion:*:*:git:*' script $HOME/.zsh/git-completion.bash @@ -86,6 +89,3 @@ source $symlink_dir/ps1.zsh # ZSH syntax highlighting must be sourced last source $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh - -# ------------------------------ END SETUP ------------------------------ # -