From 076ddb88b5161bc0e8882e38c01fd254a67e17d4 Mon Sep 17 00:00:00 2001 From: Andrei Jiroh Halili Date: Sat, 13 Apr 2024 11:25:23 +0000 Subject: [PATCH] Fix hostname detection on bashrc Also in this commit, I do "git remote add" to the sourcehut mirror of my dotfiles if not exists locally Signed-off-by: Andrei Jiroh Halili --- .bashrc | 15 ++++++++++----- .config/yadm/bootstrap.d/00-post-clone-repo.sh | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.bashrc b/.bashrc index d7e7158..0b77504 100644 --- a/.bashrc +++ b/.bashrc @@ -12,9 +12,11 @@ if [[ $TERMUX ]]; then export SSH_AGENT_=todo elif command -v keychain >> /dev/null; then - export KEYCHAIN_PATh=$(command -v keychain) + # shellcheck disable=SC2155 + export KEYCHAIN_PATH=$(command -v keychain) eval $(keychain --agents gpg,ssh --eval) fi +# shellcheck disable=SC2155 export GPG_TTY=$(tty) # how about detecting local configs @@ -28,6 +30,7 @@ else if [[ $PROMPT_THEME == "disabled" ]]; then true elif [[ -f "$HOME/.config/bash/shell-prompts/${PROMPT_THEME}.bashrc" ]]; then + # shellcheck disable=SC1090 source "$HOME/.config/bash/shell-prompts/${PROMPT_THEME}.bashrc" else source "$HOME/.config/bash/shell-prompts/vern.bashrc" @@ -56,19 +59,21 @@ export LOCALE_ARCHIVE="$HOME/.nix-profile/lib/locale/locale-archive" ## Stage 2: Source literally everything else ## if [[ -d "$HOME/.bashbox" ]]; then + # shellcheck disable=SC1091 source "$HOME/.bashbox/env" fi # handle hostname generation for importing host-specific configs # TODO: Handle detection when we don't have WSL_* variables on tmux shell sessions if [[ $WSL_DISTRO_NAME ]] && [[ $WSL_INTEROP ]]; then - HOSTNAME_BASH="${HOSTNAME}-wsl-${WSL_DISTRO_NAME}" + HOSTNAME_BASH="$(cat /etc/hostname)-wsl-${WSL_DISTRO_NAME}" export WSL=1 # similar to CODESPACES and GITPOD_WORKSPACE_ID vars else - HOSTNAME_BASH="${HOSTNAME}" + HOSTNAME_BASH="$(cat /etc/hostname)" fi +export HOSTNAME_BASH for file in "$HOME/.config/bash/hosts/${HOSTNAME_BASH}.bashrc" "${HOME}/.config/bash/bashrc"; do - [ -f $file ] && . "$file" + # shellcheck disable=SC1090 + [ -f "$file" ] && . "$file" done - diff --git a/.config/yadm/bootstrap.d/00-post-clone-repo.sh b/.config/yadm/bootstrap.d/00-post-clone-repo.sh index 827a8d8..af8394a 100755 --- a/.config/yadm/bootstrap.d/00-post-clone-repo.sh +++ b/.config/yadm/bootstrap.d/00-post-clone-repo.sh @@ -11,5 +11,5 @@ elif [ -d "$HOME/.git" ] && [ ! -d "$HOME/.local/share/yadm/repo.git" ]; then fi echo "Setting git remote URLs to SSH" -git remote set-url origin ssh://git@mau.dev/andreijiroh.dev/dotfiles || true -git remote set-url hut ssh://git@git.sr.ht/~ajhalili2006/dotfiles || true +git remote set-url --add origin ssh://git@mau.dev/andreijiroh.dev/dotfiles || true +git remote set-url --add hut ssh://git@git.sr.ht/~ajhalili2006/dotfiles || git remote add hut ssh://git@git.sr.ht/~ajhalili2006/dotfiles