From df8d184d5afc994085c16480104d5f58dae7d00d Mon Sep 17 00:00:00 2001 From: Robert Spencer <rspencer@lbsd.net> Date: Fri, 11 Jan 2019 17:19:34 +0200 Subject: [PATCH] Friendlier customization Previously doing more than superficial changes would result in a dirty working directory. In addition some changes in your local configuration would not overrule upstream configuration files. This commit fixes both those issues. --- .gitignore | 2 +- README.md | 2 +- completion/.gitignore | 4 ++++ contrib/awit-ssh-completion/INSTALL | 6 +++--- custom/.gitignore | 2 ++ custom/lib/.gitignore | 2 ++ custom/plugins/.gitignore | 6 ++++++ custom/themes/.gitignore | 6 ++++++ zshrc | 18 ++++++++++++++++-- zshrc_local.d/.gitignore | 4 ++++ 10 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 completion/.gitignore create mode 100644 custom/.gitignore create mode 100644 custom/lib/.gitignore create mode 100644 custom/plugins/.gitignore create mode 100644 custom/themes/.gitignore create mode 100644 zshrc_local.d/.gitignore diff --git a/.gitignore b/.gitignore index 0fb347a..88e8899 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -zshrc.local cache +zshrc.local diff --git a/README.md b/README.md index 9b20eca..e1d8bed 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ # Customizing -Customizing can be done by editing the .zsh/zshrc.local file. +Customizing can be done by adding files to ~/.zsh/zshrc_local.d/ directory and editing the ~/.zsh/zshrc.local file. If you have something awesome to contribute, please consider adding it to zshrc.d/. diff --git a/completion/.gitignore b/completion/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/completion/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/contrib/awit-ssh-completion/INSTALL b/contrib/awit-ssh-completion/INSTALL index 5b4e5bf..3b76f6a 100755 --- a/contrib/awit-ssh-completion/INSTALL +++ b/contrib/awit-ssh-completion/INSTALL @@ -20,10 +20,10 @@ fi if [ ! -e ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh ]; then # Install - ln -s ~/.zsh/contrib/awit-ssh-completion/51-completion-awit-ssh.zsh ~/.zsh/zshrc.d/ + ln -s ~/.zsh/contrib/awit-ssh-completion/51-completion-awit-ssh.zsh ~/.zsh/zshrc_local.d/ echo "Installed ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh" else # Uninstall - rm -f ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh - echo "Uninstalled ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh" + rm -f ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh ~/.zsh/zshrc_local.d/51-completion-awit-ssh.zsh + echo "Uninstalled ~/.zsh/zshrc.d/51-completion-awit-ssh.zsh and ~/.zsh/zshrc_local.d/51-completion-awit-ssh.zsh" fi diff --git a/custom/.gitignore b/custom/.gitignore new file mode 100644 index 0000000..cf1c3b0 --- /dev/null +++ b/custom/.gitignore @@ -0,0 +1,2 @@ +# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals +*.zsh diff --git a/custom/lib/.gitignore b/custom/lib/.gitignore new file mode 100644 index 0000000..cf1c3b0 --- /dev/null +++ b/custom/lib/.gitignore @@ -0,0 +1,2 @@ +# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-internals +*.zsh diff --git a/custom/plugins/.gitignore b/custom/plugins/.gitignore new file mode 100644 index 0000000..2256885 --- /dev/null +++ b/custom/plugins/.gitignore @@ -0,0 +1,6 @@ +# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-and-adding-plugins +# +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/custom/themes/.gitignore b/custom/themes/.gitignore new file mode 100644 index 0000000..98903b4 --- /dev/null +++ b/custom/themes/.gitignore @@ -0,0 +1,6 @@ +# https://github.com/robbyrussell/oh-my-zsh/wiki/Customization#overriding-and-adding-themes +# +# Ignore everything in this directory +* +# Except this file +!.gitignore diff --git a/zshrc b/zshrc index 60a3417..8a38c61 100644 --- a/zshrc +++ b/zshrc @@ -2,10 +2,24 @@ setopt EXTENDED_GLOB # Source in resources -for F in ~/.zsh/zshrc.d/([a-zA-Z0-9-]##).zsh; do - source $F +find ~/.zsh/zshrc{,_local}.d/([a-zA-Z0-9-]##).zsh | sort -t/ -k6,6 | while read LINE; do + DIR="${LINE%/*}" + FILE="${LINE##*/}" + + # If there's a file in zshrc_local.d with the same name as one + # in zshrc.d, ignore the file in zshrc.d + if [[ "$DIR" =~ "zshrc.d" ]] && [ -e "~/.zsh/zshrc_local.d/$FILE" ]; then + # Do nothing + : + else + source "$LINE" + fi done +# NB: Note that precedence matters, so some settings will not yield the +# expected results when put into ~/.zsh/zshrc.local. In that case you need +# to figure out the file number and put it into ~/.zsh/zshrc_local.d/ + # Source in local stuff if [ -f ~/.zsh/zshrc.local ] then diff --git a/zshrc_local.d/.gitignore b/zshrc_local.d/.gitignore new file mode 100644 index 0000000..5e7d273 --- /dev/null +++ b/zshrc_local.d/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore -- GitLab