From 791f4ae7b7685d1bdbf5c3323d5585087701a4f8 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:47:04 -0500 Subject: [PATCH 1/5] feat: Replace shell execution with shell variable --- dot_hooks.tmpl | 9 +++++---- executable_dot_bashrc.tmpl | 1 + executable_dot_zshrc.tmpl | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dot_hooks.tmpl b/dot_hooks.tmpl index a025c71..71a5e17 100644 --- a/dot_hooks.tmpl +++ b/dot_hooks.tmpl @@ -1,6 +1,7 @@ +# shellcheck shell=sh # >>> conda initialize >>> # !! Contents within this block are managed by 'conda init' !! -__conda_setup="$($HOME/miniconda3/bin/conda shell.$(basename $(readlink -f /proc/$$/exe)) 'hook' 2> /dev/null)" +__conda_setup="$($HOME/miniconda3/bin/conda shell.$SH 'hook' 2> /dev/null)" if [ $? -eq 0 ]; then eval "$__conda_setup" else @@ -18,7 +19,7 @@ fi # <<< conda initialize <<< {{- if lookPath "direnv" }} -eval "$(direnv hook $(basename $(readlink -f /proc/$$/exe)))" +eval "$(direnv hook $SH)" {{- end }} if [ -f $HOME/.ion/bin/ion ]; then @@ -27,8 +28,8 @@ if [ -f $HOME/.ion/bin/ion ]; then fi # Import GNU parallel -if [ $(command -v env_parallel.$(basename $(readlink -f /proc/$$/exe))) ]; then - source $(which env_parallel.$(basename $(readlink -f /proc/$$/exe))) +if [ $(command -v env_parallel.$SH) ]; then + source $(which env_parallel.$SH) fi {{- if eq .machinetype "workstation" }} diff --git a/executable_dot_bashrc.tmpl b/executable_dot_bashrc.tmpl index 34b39c0..ceb87b1 100644 --- a/executable_dot_bashrc.tmpl +++ b/executable_dot_bashrc.tmpl @@ -1,5 +1,6 @@ # shellcheck shell=bash # .bashrc +export SH=bash if [ -f "$HOME/.modules" ]; then source $HOME/.modules diff --git a/executable_dot_zshrc.tmpl b/executable_dot_zshrc.tmpl index 4529d6f..3f80f0e 100644 --- a/executable_dot_zshrc.tmpl +++ b/executable_dot_zshrc.tmpl @@ -1,3 +1,4 @@ +export SH=zsh {{- if eq .chezmoi.os "linux" }} {{- if or (eq .machinetype "workstation") From ad7c7b7a4ec871f5f71bbd3e41768a98aaefda9b Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:57:26 -0500 Subject: [PATCH 2/5] feat: Add nproc alias for osx --- dot_aliases.tmpl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dot_aliases.tmpl b/dot_aliases.tmpl index 45b6949..ec25204 100644 --- a/dot_aliases.tmpl +++ b/dot_aliases.tmpl @@ -12,6 +12,11 @@ alias ls=lsd alias code=codium {{- end }} +# Platform-specific aliases +{{- if eq .chezmoi.os "darwin" }} +alias nproc='sysctl -n hw.logicalcpu' +{{- end }} + # Universal aliases alias config='git --git-dir=$HOME/.cfg/ --work-tree=$HOME' alias please='sudo $(fc -ln -1)' From ceefb8697eed5eb02fecae59603daa4b7b1ecb76 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Fri, 6 Oct 2023 10:57:59 -0500 Subject: [PATCH 3/5] refactor: Rearrange aliases to be in place before hooks --- executable_dot_bashrc.tmpl | 6 +++--- executable_dot_zshrc.tmpl | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/executable_dot_bashrc.tmpl b/executable_dot_bashrc.tmpl index ceb87b1..619df33 100644 --- a/executable_dot_bashrc.tmpl +++ b/executable_dot_bashrc.tmpl @@ -6,12 +6,12 @@ if [ -f "$HOME/.modules" ]; then source $HOME/.modules fi -# Hook virtual environment modifers -source $HOME/.hooks - # User specific aliases and functions source $HOME/.aliases +# Hook virtual environment modifers +source $HOME/.hooks + source $HOME/.envvar # Make the prompt pretty, just in case we're stuck in bash land diff --git a/executable_dot_zshrc.tmpl b/executable_dot_zshrc.tmpl index 3f80f0e..65f82b2 100644 --- a/executable_dot_zshrc.tmpl +++ b/executable_dot_zshrc.tmpl @@ -52,6 +52,9 @@ antigen theme https://gist.github.com/efde5e8d507bd3e1e046198b69d579f8.git gianu HYPHEN_INSENSITIVE="true" COMPLETION_WAITING_DOTS="true" +alias zshconfig="$EDITOR ~/.zshrc" +source $HOME/.aliases + source $HOME/.hooks # Tell Antigen that you're done @@ -65,8 +68,6 @@ bashcompinit source $HOME/.envvar -alias zshconfig="$EDITOR ~/.zshrc" -source $HOME/.aliases {{- if eq .chezmoi.os "linux" }} {{ if or From dc626c4ed9d07d731be86a640ca99a28fe0d0629 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:01:42 -0500 Subject: [PATCH 4/5] fix: Add p10k config for Darwin --- executable_dot_zshrc.tmpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/executable_dot_zshrc.tmpl b/executable_dot_zshrc.tmpl index 65f82b2..210e161 100644 --- a/executable_dot_zshrc.tmpl +++ b/executable_dot_zshrc.tmpl @@ -1,5 +1,5 @@ export SH=zsh -{{- if eq .chezmoi.os "linux" }} +{{ if or (eq .chezmoi.os "linux") (eq .chezmoi.os "darwin") }} {{- if or (eq .machinetype "workstation") (eq .chezmoi.osRelease.id "fedora") @@ -69,7 +69,7 @@ bashcompinit source $HOME/.envvar -{{- if eq .chezmoi.os "linux" }} +{{ if or (eq .chezmoi.os "linux") (eq .chezmoi.os "darwin") }} {{ if or (eq .machinetype "workstation") (eq .chezmoi.osRelease.id "fedora") From 632f8edf4ddad9b049dd6d31427e6fae1243c273 Mon Sep 17 00:00:00 2001 From: "Thomas A. Christensen II" <25492070+MillironX@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:07:36 -0500 Subject: [PATCH 5/5] feat: Replace linuxbrew hook with Homebrew hook --- dot_profile => dot_profile.tmpl | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) rename dot_profile => dot_profile.tmpl (52%) diff --git a/dot_profile b/dot_profile.tmpl similarity index 52% rename from dot_profile rename to dot_profile.tmpl index 01f5e0d..035d52a 100644 --- a/dot_profile +++ b/dot_profile.tmpl @@ -7,18 +7,10 @@ export PATH="$HOME/.julia/bin:$PATH" export PATH="$HOME/.julia/juliaup/bin:$PATH" export PATH="$HOME/.juliaup/bin:$PATH" -# Linuxbrew setup -if [ -d $HOME/../linuxbrew/.linuxbrew ]; then - BREWPATH=$HOME/../linuxbrew/.linuxbrew -elif [ -d $HOME/.linuxbrew ]; then - BREWPATH=$HOME/.linuxbrew -fi - -if [ -n "$BREWPATH" ]; then - eval "$($BREWPATH/bin/brew shellenv)" - export HOMEBREW_MAKE_JOBS=1 - export HOMEBREW_NO_ANALYTICS=1 -fi +{{ if eq .chezmoi.os "darwin" }} +# Homebrew setup +eval "$(/opt/homebrew/bin/brew shellenv)" +{{ end }} if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh"