From 8599d7c7cfe652da5e6213860099374d0288e8a1 Mon Sep 17 00:00:00 2001 From: Jeremy Kaplan Date: Wed, 25 Sep 2024 18:16:06 -0400 Subject: [PATCH] zsh: Try splitting zprofile by OS --- darwin.conf.yaml | 4 ++-- default.conf.yaml | 2 -- etc/profile | 8 ------- zsh/.zprofile => etc/profile.darwin | 4 ++++ etc/profile.linux | 33 +++++++++++++++++++++++++++++ linux.conf.yaml | 1 + zsh/.zshrc | 1 - 7 files changed, 40 insertions(+), 13 deletions(-) delete mode 100644 etc/profile rename zsh/.zprofile => etc/profile.darwin (90%) create mode 100644 etc/profile.linux diff --git a/darwin.conf.yaml b/darwin.conf.yaml index ac85362..46c372a 100644 --- a/darwin.conf.yaml +++ b/darwin.conf.yaml @@ -1,6 +1,5 @@ - shell: - - - command: brew/install + - command: brew/install stdout: true stderr: true quiet: false @@ -12,3 +11,4 @@ ~/.config/aerospace: aerospace/ ~/.config/karabiner: karabiner/ ~/.config/tridactyl: tridactyl/ + ~/.profile: etc/profile.darwin diff --git a/default.conf.yaml b/default.conf.yaml index 7f2eda5..90edef7 100644 --- a/default.conf.yaml +++ b/default.conf.yaml @@ -32,12 +32,10 @@ ~/.ignore: etc/ignore ~/.my.cnf: mysql/.my.cnf ~/.npmrc: npm/.npmrc - ~/.profile: etc/profile ~/.psqlrc: psql/.psqlrc ~/.rgignore: etc/rgignore ~/.tmux.conf: tmux/.tmux.conf ~/.vimrc: vim/.vimrc ~/.vim: vim/ - ~/.zprofile: zsh/.zprofile ~/.zshenv: zsh/.zshenv ~/.zshrc: zsh/.zshrc diff --git a/etc/profile b/etc/profile deleted file mode 100644 index 8475c9a..0000000 --- a/etc/profile +++ /dev/null @@ -1,8 +0,0 @@ -has() { - command -V "$1" > /dev/null 2>&1 -} - -if has gnome-keyring-daemon; then - eval "$(gnome-keyring-daemon --start)" - export SSH_AUTH_SOCK -fi diff --git a/zsh/.zprofile b/etc/profile.darwin similarity index 90% rename from zsh/.zprofile rename to etc/profile.darwin index aed9db7..be19bae 100644 --- a/zsh/.zprofile +++ b/etc/profile.darwin @@ -1,3 +1,7 @@ +has() { + command -V "$1" > /dev/null 2>&1 +} + source_if() { if [ -e "$1" ]; then source "$1" diff --git a/etc/profile.linux b/etc/profile.linux new file mode 100644 index 0000000..e7df60a --- /dev/null +++ b/etc/profile.linux @@ -0,0 +1,33 @@ +has() { + command -V "$1" > /dev/null 2>&1 +} + +source_if() { + if [ -e "$1" ]; then + source "$1" + fi +} + +path_if() { + if [ -d "$1" ]; then + case ":$PATH:" in + *:"$1":*) + ;; + *) + PATH="${1}${PATH:+:$PATH}" + esac + fi +} + +source_if "${HOME}/.nix-profile/etc/profile.d/nix.sh" + +path_if "$HOME/bin" +path_if "$HOME/.local/bin" + +unset -f source_if +unset -f path_if + +if has gnome-keyring-daemon; then + eval "$(gnome-keyring-daemon --start)" + export SSH_AUTH_SOCK +fi diff --git a/linux.conf.yaml b/linux.conf.yaml index a85615f..8962d39 100644 --- a/linux.conf.yaml +++ b/linux.conf.yaml @@ -1,4 +1,5 @@ - link: ~/.config/user-dirs.dirs: etc/user-dirs.dirs + ~/.profile: etc/profile.linux ./alacritty/os.toml: alacritty/linux.toml ./zsh/os.zshrc: zsh/linux.zshrc diff --git a/zsh/.zshrc b/zsh/.zshrc index ff9a586..fbd287f 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -73,7 +73,6 @@ ${prompt}" export RPROMPT='' # aliases -source $HOME/.zprofile source $HOME/.config/zsh/aliases source $HOME/.config/zsh/j.sh