Skip to content

Instantly share code, notes, and snippets.

@hoyhoy
Last active August 14, 2026 16:12
Show Gist options
  • Select an option

  • Save hoyhoy/2829b5340e5d328eeb6b7284ba8365ff to your computer and use it in GitHub Desktop.

Select an option

Save hoyhoy/2829b5340e5d328eeb6b7284ba8365ff to your computer and use it in GitHub Desktop.
What I use instead of Gnu Stow ...
display_banner() {
if [ "${SUPPRESS_BANNER:-}" == "yes" ] || [[ -z "${TERM:-}" ]]; then
return
fi
# Get terminal width
local banner_length=$(($(tput cols)))
# Set minimum banner length
if (( banner_length < 40 )); then
return # Don't display if terminal is too small
fi
local adjust=0
# Allow override if provided
if [ -n "${3:-}" ]; then
adjust="${3:-}"
fi
# Colors
red='\033[0;31m'
green='\033[0;32m'
white='\033[0;97m'
lightmagenta='\033[0;35m'
lightfaintgray='\033[2;90m'
darkyellow='\033[0;33m'
dimyellow='\033[2;33m'
nc='\033[0m'
local banner_type="${1:-}"
local message="${2:-}"
# Calculate widths
local line_width=$((banner_length - 2))
local max_message_length=$((banner_length - 6))
local text_width=$((banner_length - 6 + adjust))
# Truncate message if too long
if (( ${#message} > max_message_length )); then
message="${message:0:${max_message_length}}"
fi
local text_color="${white}"
local banner_color="${lightfaintgray}"
local icon=""
local icon_color=""
# Set banner style based on type
if [ "${banner_type}" == "fail" ]; then
banner_color="${red}"
icon="" # nf-fa-times_circle
icon_color="${red}"
elif [ "${banner_type}" == "warning" ]; then
banner_color="${dimyellow}"
icon="" # nf-fa-exclamation_triangle
icon_color="${darkyellow}"
elif [ "${banner_type}" == "success" ]; then
banner_color="${green}"
icon="" # nf-fa-check_circle
icon_color="${green}"
elif [ "${banner_type}" == "highlight" ]; then
banner_color="${lightmagenta}"
icon="" # nf-fa-star
icon_color="${lightmagenta}"
elif [ "${banner_type}" == "status" ]; then
banner_color="${lightfaintgray}"
icon="" # nf-fa-info_circle
icon_color="${lightfaintgray}"
fi
# Top border
printf "${banner_color}"
printf '─%.0s' $(seq 1 ${line_width})
printf "╮\n"
# Content line
printf "${banner_color}${icon_color}${icon}${text_color} %${text_width}s ${banner_color}│\n" "${message}"
# Bottom border
printf ""
printf '─%.0s' $(seq 1 ${line_width})
printf "${nc}\n"
}
deploy_dotfiles() {
deploy_dotfile() {
src_dot_file_name="${1:-}"
dest_dot_file_name="${2:-}"
if [ -z "${src_dot_file_name}" ]; then
display_banner fail "argument 1 (src_dot_file_name) must be defined"
return
fi
if [ -z "${dest_dot_file_name}" ]; then
display_banner fail "argument 2 (dest_dot_file_path) must be defined"
return
fi
local src_dot_file_path="${HOME}/dot-files/${src_dot_file_name}"
local dest_dot_file_path="${HOME}/${dest_dot_file_name}"
if [[ -d "${dest_dot_file_path}" ]] && [[ "${dest_dot_file_path}" != "${HOME}" ]]; then
rm -Rf "${dest_dot_file_path}"
fi
if [[ "${dest_dot_file_name}" =~ / ]]; then
dest_dot_file_parent_dir="${HOME}/$(dirname ${dest_dot_file_name})"
if [[ ! -d "${dest_dot_file_parent_dir}" ]]; then
mkdir -p "${dest_dot_file_parent_dir}"
fi
fi
ln -fs "${src_dot_file_path}" "${dest_dot_file_path}"
if [[ -e "${dest_dot_file_path}" ]]; then
display_banner success "deployed ${src_dot_file_path}${dest_dot_file_path}" 2
if [[ "${dest_dot_file_name}" == ".netrc" ]]; then
display_banner success "chmod 600 ${src_dot_file_path}"
chmod 0600 "${src_dot_file_path}"
chmod 0600 "${dest_dot_file_path}"
fi
else
display_banner fail "failed to deploy ${src_dot_file_path}${dest_dot_file_path}" 2
fi
}
deploy_dotfile dot-config .config
if [[ "$(hostname)" == "whitefall" ]]; then
deploy_dotfile dot-config/starship/starship.whitefall.toml .config/starship.toml
if [[ ! -f .config/systemd ]]; then
deploy_dotfile systemd-rhel8 .config/systemd
fi
elif [[ "$(hostname)" == "zbuild2" ]]; then
deploy_dotfile dot-config/starship/starship.zbuild2.toml .config/starship.toml
elif [[ "$(hostname)" == "nixos" ]]; then
deploy_dotfile dot-config/starship/starship.nixos.toml .config/starship.toml
elif [[ "$(hostname)" == "haven" ]]; then
deploy_dotfile dot-config/starship/starship.nixos.toml .config/starship.toml
elif [[ "$(hostname)" == "groot.local" ]]; then
deploy_dotfile dot-config/starship/starship.groot.toml .config/starship.toml
elif [[ "$(hostname)" == "meson" ]]; then
deploy_dotfile dot-config/starship/starship.miranda.toml .config/starship.toml
elif [[ "$(hostname)" == "omnios" ]]; then
deploy_dotfile dot-config/starship/starship.omnios.toml .config/starship.toml
elif [[ "$(hostname)" == "miranda" ]]; then
deploy_dotfile dot-config/starship/starship.miranda.toml .config/starship.toml
elif [[ "$(hostname)" == "rhel10" ]]; then
deploy_dotfile dot-config/starship/starship.rhel10.toml .config/starship.toml
elif [[ "$(hostname)" == "rhel9" ]]; then
deploy_dotfile dot-config/starship/starship.rhel9.toml .config/starship.toml
elif [[ "$(hostname)" == "void" ]]; then
deploy_dotfile dot-config/starship/starship.void.toml .config/starship.toml
elif [[ "$(hostname)" == "fedora" ]]; then
deploy_dotfile dot-config/starship/starship.fedora43.toml .config/starship.toml
elif [[ "$(hostname)" == "ibm-fedora" ]]; then
deploy_dotfile dot-config/starship/starship.fedora43.toml .config/starship.toml
elif [[ "$(hostname)" == "absaroka" ]] && [[ -n "${WSL_DISTRO_NAME:-}" ]]; then
deploy_dotfile dot-config/starship/starship.win10.toml .config/starship.toml
fi
if [[ -f "/etc/os-release" ]]; then
[[ -z "${ID:-}" ]] && . /etc/os-release
if [[ "${ID:-}" == "fedora" ]]; then
deploy_dotfile dot-bash-history.fedora .bash_history
deploy_dotfile dot-bash-login .bashrc
elif [[ "${ID:-}" == "nixos" ]]; then
deploy_dotfile dot-bash-login .bash_login
deploy_dotfile dot-bash-history.nixos .bash_history
elif [[ "${ID:-}" == "void" ]]; then
deploy_dotfile dot-bash-login .bashrc
deploy_dotfile dot-bash-history.void .bash_history
elif [[ "${PLATFORM_ID:-}" == "platform:el8" ]]; then
deploy_dotfile dot-bash-login .bashrc
deploy_dotfile dot-bash-history.rhel8 .bash_history
elif [[ "${PLATFORM_ID:-}" == "platform:el9" ]]; then
deploy_dotfile dot-bash-login .bashrc
deploy_dotfile dot-bash-history.rhel9 .bash_history
elif [[ "${PLATFORM_ID:-}" == "platform:el10" ]]; then
deploy_dotfile dot-bash-login .bashrc
deploy_dotfile dot-bash-history.rhel10 .bash_history
else
echo "Unsupported Linux distribution/version"
fi
elif [[ -n "$WSL_DISTRO_NAME" ]]; then
deploy_dotfile dot-bash-history.wsl .bash_history
elif [[ "$(uname)" == "Linux" ]]; then
echo "Cannot determine Linux distribution"
fi
if [[ "$(uname)" == "Darwin" ]]; then
deploy_dotfile dot-bash-login .bash_login
deploy_dotfile dot-bash-history.macos .bash_history
elif [[ "$(uname)" == "OpenBSD" ]]; then
deploy_dotfile dot-bash-login .bash_login
deploy_dotfile dot-bash-history.openbsd .bash_history
elif [[ "$(uname)" == "Linux" ]]; then
deploy_dotfile dot-rmate.rc .rmate.rc
deploy_dotfile dot-gdbinit .gdbinit
fi;
deploy_dotfile dot-bundle/config .bundle/config
deploy_dotfile dot-ssh/config .ssh/config
chmod go-wrx ${HOME}/.ssh/config
if [[ "$(hostname)" == "miranda" ]]; then
deploy_dotfile dot-ssh/config-miranda .ssh/config-local
elif [[ "$(hostname)" == "meson" ]]; then
deploy_dotfile dot-ssh/config-meson .ssh/config-local
elif [[ "$(uname)" == "Linux" ]]; then
deploy_dotfile dot-ssh/config-linux .ssh/config-local
fi;
if [[ -f "${HOME}/.ssh/config-local" ]]; then
chmod go-wrx ${HOME}/.ssh/config-local
fi
deploy_dotfile bashrc.d .bashrc.d
deploy_dotfile dot-aws .aws
deploy_dotfile dot-aspera-cloud-credentials .aspera_cloud_test_credentials.yml
deploy_dotfile dot-inputrc .inputrc
deploy_dotfile dot-bashrc.global.sh .bashrc.global
deploy_dotfile dot-rediscli-history .rediscli_history
deploy_dotfile dot-hushlogin .hushlogin
deploy_dotfile dot-irssi .irssi
deploy_dotfile dot-clang-tidy .clang-tidy
deploy_dotfile dot-wgetrc .wgetrc
deploy_dotfile dot-netrc .netrc
deploy_dotfile dot-lldb .lldb
deploy_dotfile dot-lldbinit .lldbinit
deploy_dotfile dot-gemrc .gemrc
deploy_dotfile dot-irb-history .irb_history
deploy_dotfile dot-irbrc .irbrc
if [[ -L ${HOME}/.nanorc ]]; then
# remove non XDG symlink
rm ${HOME}/.nanorc
fi
if [[ -L ${HOME}/.nano ]]; then
# remove non XDG symlink
rm ${HOME}/.nano
fi
deploy_dotfile dot-cmake-format.yaml .cmake-format.yaml
deploy_dotfile dot-rspec .rspec
deploy_dotfile dot-rspec-parallel .rspec_parallel
if [[ "$(uname)" == "Linux" ]]; then
deploy_dotfile dot-gdb-history .gdb_history
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment