From fa022cc8cd7a53b3ab0b4d89c5eedc071377c191 Mon Sep 17 00:00:00 2001
From: Justin Hileman <justin@justinhileman.info>
Date: Sat, 15 Nov 2014 22:16:01 -0800
Subject: [PATCH] Add local-config plugin.

Support per-user, per-host, and per-platform custom configuration files.
---
 plugins/README.markdown                |  1 +
 plugins/local-config/local-config.load | 30 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+)
 create mode 100644 plugins/local-config/local-config.load

diff --git a/plugins/README.markdown b/plugins/README.markdown
index 048654a..0aec477 100644
--- a/plugins/README.markdown
+++ b/plugins/README.markdown
@@ -14,6 +14,7 @@
 * __gem__ – Ruby gem integration.
 * __gi__ – [gitignore.io](http://gitignore.io) CLI for fish.
 * __jump__ – A port of [Jeroen Janssens’ “jump” utility](http://jeroenjanssens.com/2013/08/16/quickly-navigate-your-filesystem-from-the-command-line.html).
+* __local-config__ – Support per-user, per-host and per-platform custom config files.
 * __localhost__ – Opens `http://localhost:3000` (and other ports) in the default browser.
 * __mc__ – Plugin to start mc with a shell compliant (Bash).
 * __ndenv__ – Helpers for [another node.js version manager](https://github.com/riywo/ndenv).
diff --git a/plugins/local-config/local-config.load b/plugins/local-config/local-config.load
new file mode 100644
index 0000000..291636a
--- /dev/null
+++ b/plugins/local-config/local-config.load
@@ -0,0 +1,30 @@
+# Load custom settings for current hostname
+set -l HOST (hostname | sed 's/\(-[0-9]\{1,\}\)\{0,1\}\(\.local\)\{0,1\}$//')
+set -l HOST_SPECIFIC_FILE $fish_custom/hosts/$HOST.fish
+if test -f $HOST_SPECIFIC_FILE
+  . $HOST_SPECIFIC_FILE
+else
+  echo Creating host specific file: $HOST_SPECIFIC_FILE
+  mkdir -p (dirname $HOST_SPECIFIC_FILE)
+  touch $HOST_SPECIFIC_FILE
+end
+
+# Load custom settings for current user
+set -l USER_SPECIFIC_FILE $fish_custom/users/(whoami).fish
+if test -f $USER_SPECIFIC_FILE
+  . $USER_SPECIFIC_FILE
+else
+  echo Creating user specific file: $USER_SPECIFIC_FILE
+  mkdir -p (dirname $USER_SPECIFIC_FILE)
+  touch $USER_SPECIFIC_FILE
+end
+
+# Load custom settings for current OS
+set -l PLATFORM_SPECIFIC_FILE $fish_custom/platforms/(uname -s).fish
+if test -f $PLATFORM_SPECIFIC_FILE
+  . $PLATFORM_SPECIFIC_FILE
+else
+  echo Creating platform specific file: $PLATFORM_SPECIFIC_FILE
+  mkdir -p (dirname $PLATFORM_SPECIFIC_FILE)
+  touch $PLATFORM_SPECIFIC_FILE
+end
-- 
GitLab