Last active
June 29, 2022 05:07
-
-
Save superatomic/52a46e53a4afce75ede4db7ba6354e0a to your computer and use it in GitHub Desktop.
Xshe Example – Cross-Shell Environment Variable Configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################################# | |
# Cross-Shell Environment Variable Configuration using Xshe # | |
# https://github.com/superatomic/xshe # | |
############################################################# | |
# Xshe allows for setting environment variable across multiple shells: | |
PS1 = '> ' | |
# These lines add the environment variables for the XDG Base Directory Specification. | |
# (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html) | |
# ~ is expanded along with all $VARS. | |
XDG_CONFIG_HOME = '~/.config' | |
XDG_DATA_HOME = '~/.local/share' | |
XDG_CACHE_HOME = '~/.cache' | |
# Another environment variable! | |
BIN_HOME = '~/.local/bin' | |
# Now, we set up another environment variable that is relative to $XDG_DATA_HOME. | |
# Because environment variables are added in the order that they appear in this file, | |
# we can be sure that $XDG_DATA_HOME will be set before we set this variable. | |
CARGO_HOME = '$XDG_DATA_HOME/cargo' | |
# You can also surround environment variable expansions with curly brackets. | |
RUSTUP_HOME = '${XDG_DATA_HOME}/rustup' | |
# Declaring paths should be done with an array of values, like this. | |
# Xshe will join them together in the correct way based on the shell that is being used. | |
PATH = ['$PATH', '$BIN_HOME', '$CARGO_HOME/bin'] | |
# We can evaluate dynamic variable values like this. | |
# Here, we set the variable $EDITOR to the location of the editor nano, wherever it is on the system. | |
EDITOR = '$(which nano)' | |
# Now, we can set environment variables for specific shells instead of all of them: | |
# $HISTFILE will only be set to this file for bash | |
HISTFILE.bash = '$XDG_STATE_HOME/bash_history' | |
# $HISTFILE will only be set to this file for zsh | |
HISTFILE.zsh = '$XDG_STATE_HOME/zsh_history' | |
# We can also set more values only for zsh: | |
ZDOTDIR.zsh = '$XDG_CONFIG_HOME/zsh' | |
ZSH_CACHE_DIR.zsh = '$XDG_CACHE_HOME/oh-my-zsh' | |
# and for fish: | |
fish_greeting.fish = 'Welcome to fish, human' | |
# We can also make set a default value to use for shells that we don"t specify. | |
# This line sets the variable $SHELL_NICKNAME to 'Shellfish' if the shell is zsh, but 'Shell' if it is anything else. | |
SHELL_NICKNAME.fish = 'Shellfish' | |
SHELL_NICKNAME._ = 'Shell' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment