Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add Feature: Local Customizations Folder (to simplify maintenance) #846

Closed
wants to merge 2 commits into from

3 participants

@thedeeno

Problem

Zsh configuration is very personal. The way "oh-my-zsh" deals with customizations has created an explosion of pull requests some of which are probably too narrow to be in the main repo. This is a maintenance burden. Imo, only generic functionality should be added to this repo - not personal adjustments and tweaks.

One solution

Allow users to make tweaks outside of the repo. This will deincentivize fork/pulls for personal changes.

In this pull I added the concept of 'local customizations'. Instead of adding tweaks to ~/.oh-my-zsh you can instead add them to ~/.zsh. You can then separately track this folder in a personal repo. I added mine to my dotfiles repo, for example.

This is backward compatible with the /custom folder, but imo we should phase that idea out. Also, adjustments in the ~/.zsh folder have precedence over those in /custom.

@sorin-ionescu

Keeping customisations outside of the repository is a bad idea. The best way to deal with personal changes useless to others is to ask people in the README to not open frivolous pull requests in the first place and to deny the pull requests of those who have not bothered to read it. The Homebrew project handles pull requests quite well.

@thedeeno

Any reasons for why it's a bad idea?

I don't think it makes sense for there to be 1000 themes in the repository. Further, the custom folder remains untouched in the main repository anyway. It's not like we're merging upstream changes into our personal custom folder. So, if custom is a special folder already, why not pull it out and make it easier to track in another repository?

Also, by leaving it in the repo your personal history is mixed with general history.

I'm not seeing why this is better at this point.

@sorin-ionescu
@thedeeno

@sorin-ionescu Your remarks are unreasonably condescending. I know how to use git, you are missing my point.

It sounds like you'd prefer to have no custom folder, since we can simply make changes directly and use git to merge. You're right, but I think you're forgetting a few use cases:

  • What if I have private information in my scripts? Should I just throw it in the public repo?
  • What if I want to be sure that I'm only overriding the oh-my-zsh core, not changing it?
  • What if I want to add my customizations to another repo without dealing with submodules?

I'm not hearing any reasons why we shouldn't at least support an external location. This is a minor patch, and enables some use-cases that are more difficult otherwise. I think a customization folder makes sense - I just don't think it should be in the core if we do one (but my patch allows both).

I think we should have a standard custom folder to support case-2, and it should be external to support case-1. Further, by making it external, I can easily add only my adjustments to another repository, case-3.

EDIT: I understand there are ways to accomplish these things with pure git. For instance, for the private info I could submodule another repository for my zsh-only private info. This adds unnecessary complexity though - especially when we're already submoduling 'oh-my-zsh' in a 'dotfiles' repo. Just because we can do this with git, doesn't mean we always should imo.

@sorin-ionescu

I do not have a superiority complex, in fact, I dest it. I should have chosen my words about learning to use Git more carefully, which were not aimed at you in particular, but members of the general public that invent all sorts of directory hierarchies just to avoid using Git who might read this issue.

  • Should you have private information in a public repository? No. Should you have private information in a private branch or a private repository? Absolutely.

  • How is overriding instead of editing helpful? You're making your shell startup slower. Make OMZ adapt to your needs. Do not adapt your needs to OMZ.

  • I am unsure to what submodules you are referring and where you think you need them.

That said. Whatever works for you, use it, but, it should not be imposed on everybody. OMZ should be simple — the basic minimum configuration necessary to get Zsh converts off the ground. It should not include every feature to support every workflow under the sun.

At the end of .zshrc, it says, 'Customize to your needs.' Users should do so.

@thedeeno

I understand your general sentiment. For me it's quite simple, if OMZ is giving users a standard place to put customizations (custom), it makes sense to put that place outside of its repo.

If, instead, this isn't a goal, then the whole custom folder idea should be dropped - changes can be made directly (to the plugin folder for instance), as you're suggesting.

These two seem mutually exclusive. This patch is merely an extension of the current choice.

You're right, to each their own - I have my fork already. This patch, however, makes sense for everyone if OMZ is sticking with the 'customization' bits.

@robbyrussell
Owner

@thedeeno Care to rebase and send over again? Apologies for the latency

@robbyrussell

WIll close for now.. resubmit when you get a chance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 21 additions and 6 deletions.
  1. +21 −6 oh-my-zsh.sh
View
27 oh-my-zsh.sh
@@ -13,13 +13,19 @@ fpath=($ZSH/functions $ZSH/completions $fpath)
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh) source $config_file
+
+# Set ZSH_LOCAL_CUSTOM path where your custom config files
+# and plugins exists, or else we will use the default ~/.zsh/
+if [[ -z "$ZSH_LOCAL" ]]; then
+ ZSH_LOCAL="$HOME/.zsh/"
+fi
+
# Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/
if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom"
fi
-
is_plugin() {
local base_dir=$1
local name=$2
@@ -29,7 +35,9 @@ is_plugin() {
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
- if is_plugin $ZSH_CUSTOM $plugin; then
+ if is_plugin $ZSH_LOCAL $plugin; then
+ fpath=($ZSH_LOCAL/plugins/$plugin $fpath)
+ elif is_plugin $ZSH_CUSTOM $plugin; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
elif is_plugin $ZSH $plugin; then
fpath=($ZSH/plugins/$plugin $fpath)
@@ -43,7 +51,9 @@ compinit -i
# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
- if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
+ if [ -f $ZSH_LOCAL/plugins/$plugin/$plugin.plugin.zsh ]; then
+ source $ZSH_LOCAL/plugins/$plugin/$plugin.plugin.zsh
+ elif [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
source $ZSH/plugins/$plugin/$plugin.plugin.zsh
@@ -52,11 +62,15 @@ done
# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh) source $config_file
+# Load all of your custom configurations from local
+for config_file ($ZSH_LOCAL/*.zsh) source $config_file
# Load the theme
if [ "$ZSH_THEME" = "random" ]
then
themes=($ZSH/themes/*zsh-theme)
+ themes+=($ZSH_CUSTOM/*zsh-theme)
+ themes+=($ZSH_LOCAL/*zsh-theme)
N=${#themes[@]}
((N=(RANDOM%N)+1))
RANDOM_THEME=${themes[$N]}
@@ -65,9 +79,10 @@ then
else
if [ ! "$ZSH_THEME" = "" ]
then
- if [ -f "$ZSH/custom/$ZSH_THEME.zsh-theme" ]
- then
- source "$ZSH/custom/$ZSH_THEME.zsh-theme"
+ if [ -f "$ZSH_LOCAL/$ZSH_THEME.zsh-theme" ]; then
+ source "$ZSH_LOCAL/$ZSH_THEME.zsh-theme"
+ elif [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then
+ source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
Something went wrong with that request. Please try again.