View on GitHub
Shell Support
Integrations of dotfiles-cli
with supported shells.
On this page
RC File Header
The dotfiles-cli
allows reloading an existing shell session easily without the need to open a new terminal tab or manually source any file. It allows reloading an active shell session by running the dotfiles reload
command.
Since it is not possible to tamper with parent shell process environment from a nested shell, the dotfiles-cli
adds a header to the RC file that enables the session reload to take place without creating a nested shell.
Supported RC files:
.zshrc
.bashrc
.bash_profile
Header example:
#############################################################################
# THIS SECTION IS AUTO-GENERATED BY THE dotfiles CLI
#
# dotfiles RELOAD SESSION
# (https://github.com/ZachiNachshon/dotfiles-cli)
# Limitation:
# It is not possible to tamper with parent shell process from a nested shell.
#
# Solution:
# The dotfiles reload command creates a new shell session which in turn
# run the RC file (this file).
# The following script will source a reload_session.sh script under
# current shell session without creating a nested shell session.
#############################################################################
# Homebrew use different folder paths for Intel/ARM architecture:
# Intel - /usr/local
# ARM - /opt/homebrew
HOMEBREW_PREFIX_PATH=""
ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
if [[ ${ARCH} == *x86_64* ]]; then
HOMEBREW_PREFIX_PATH="/usr/local"
elif [[ ${ARCH} == *arm* ]]; then
HOMEBREW_PREFIX_PATH="/opt/homebrew"
else
echo "Architecture is not supported by dotfiles-cli. name: ${ARCH}"
fi
if [[ -n ${HOMEBREW_PREFIX_PATH} ]]; then
dotfiles_cli_install_path=$(command -v dotfiles)
# Path resolution to support Homebrew installation
if [[ ${dotfiles_cli_install_path} == ${HOMEBREW_PREFIX_PATH}/bin/dotfiles ]]; then
homebrew_dotfiles_cli_install_path=$(dirname $(readlink ${dotfiles_cli_install_path}))
homebrew_dotfiles_cli_install_path=${homebrew_dotfiles_cli_install_path/bin/libexec}
homebrew_dotfiles_cli_install_path=${homebrew_dotfiles_cli_install_path/..\/Cellar/${HOMEBREW_PREFIX_PATH}/Cellar}
DOTFILES_CLI_INSTALL_PATH=${homebrew_dotfiles_cli_install_path}
fi
DOTFILES_CLI_INSTALL_PATH=${DOTFILES_CLI_INSTALL_PATH:-${HOME}/.config/dotfiles-cli}
DOTFILES_CLI_RELOAD_SESSION_SCRIPT_PATH=${DOTFILES_CLI_INSTALL_PATH}/reload_session.sh
if [[ -e ${DOTFILES_CLI_RELOAD_SESSION_SCRIPT_PATH} ]]; then
export LOGGER_SILENT=True
source ${DOTFILES_CLI_RELOAD_SESSION_SCRIPT_PATH}
else
echo -e 'Dotfiles CLI is not installed, cannot load plugins/reload session. path: ${DOTFILES_CLI_INSTALL_PATH}'
fi
fi
Do not change the header location on the RC file since other session related content (
exports
/ aliases
) might rely on the reloaded sources.