Skip to content
Managing machine-specific changes to your dotfiles 🌋
Branch: master
Clone or download
Latest commit b81aa6e Jan 2, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.


Source files depending on your current workstation

Locality is a simple shell script that allows you to change file paths based on a set of environment variables. This is very useful if you work on multiple workstations and want to load a customized configuration on each one.

Say you have the workstations home and work. You use zsh on both, and so have a .zshrc that you keep in sync using your dotfile manager of choice. But there are some customizations that are exclusive to each workstation. You could simply add this to your .zshrc and put any customizations in there:

source ~/.zshrc.local

However, this comes with the caveat of not being able to keep this file in sync across multiple workstations, thus losing access to it.

Locality helps you with that by resolving file paths to a file that depends on your current workstation.

Getting started

Locality is at its core a shell script. A zsh plugin is also provided.

Basic Installation

Clone this repository and add the folder to your $PATH.

git clone && export PATH=$PWD/locality:$PATH

Installation as ZSH Plugin

You can also use the plugin manager of your choice to install Locality


zplug "hschne/locality"


antigen bundle hschne/locality

Oh my Zsh

 git clone ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/locality


Create the locality configuration file in ~/.config/.locality and specify the current location, for example:

echo "LOCALITY=work" > ~/.config/.locality

Run locality with a given file path to get a localized version of it:

locality $HOME/.zshrc # Returns $HOME/.work.zshrc - hidden files remain hidden
locality $HOME/somefile # $HOME/work.somefile

Install using the plugin manager of your choice.

Advanced Usage

You can use Locality to load custom configurations for a variety of tools. Basically anything that can run bash scripts can somehow use Locality.


To load a custom .zshrc For example, add this to your .zshrc.

source $(locality $HOME/.zshrc) # Load '$HOME/.<locality>.zshrc'

If you installed the Locality zsh plugin you may also use the built-in locality-load function, which handles things like invalid files

locality-load $HOME/.zshrc # sources $HOME/.locality.zsh


To use locality within Vim and load a custom configuration file add this to your .vimrc:

let locality_file = system('locality $HOME/.vimrc') 
exec "source " . locality_file " Sources $HOME/.<locality>.vim


MIT (c) @hschne

You can’t perform that action at this time.