From 49569cc127e7ce0d1973c44db4ecb7d666742b44 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 16 Nov 2024 12:34:01 -0700 Subject: [PATCH] add jj to prompt status and direnv to installed packages --- .chezmoidata/packages.yaml | 11 +++++-- dot_config/jj/config.toml.tmpl | 11 +++++++ dot_config/private_fish/config.fish | 6 ++-- .../functions/_insert_jj_after_git.fish | 18 ++++++++++ .../private_fish/functions/_tide_item_jj.fish | 33 +++++++++++++++++++ run_once_after_install2.sh.tmpl | 2 ++ run_onchange_install-packages.sh.tmpl | 2 +- 7 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 dot_config/jj/config.toml.tmpl create mode 100644 dot_config/private_fish/functions/_insert_jj_after_git.fish create mode 100644 dot_config/private_fish/functions/_tide_item_jj.fish diff --git a/.chezmoidata/packages.yaml b/.chezmoidata/packages.yaml index eda855b..8c02936 100644 --- a/.chezmoidata/packages.yaml +++ b/.chezmoidata/packages.yaml @@ -4,22 +4,26 @@ packages: - git - curl - fish + - direnv linux: dnfs: - git-all - curl - bash - fish + - direnv apts: - git - - curl - - bash - - fish + - curl + - bash + - fish + - direnv apks: - git - curl - bash - fish + - direnv webman: pkgs: - bat @@ -27,5 +31,6 @@ packages: - fzf - zellij - nvim + - jj groups: - modern-unix diff --git a/dot_config/jj/config.toml.tmpl b/dot_config/jj/config.toml.tmpl new file mode 100644 index 0000000..cacf565 --- /dev/null +++ b/dot_config/jj/config.toml.tmpl @@ -0,0 +1,11 @@ +[user] +name = {{ .name | quote }} +email = {{ .email | quote }} + +[ui] +editor = "nvim" +merge-editor = "vscode" +pager = "delta" + +[ui.diff] +format = "git" diff --git a/dot_config/private_fish/config.fish b/dot_config/private_fish/config.fish index 7e889db..fb46112 100644 --- a/dot_config/private_fish/config.fish +++ b/dot_config/private_fish/config.fish @@ -1,11 +1,15 @@ if status is-interactive # Commands to run in interactive sessions can go here + functions -q _insert_jj_after_git; and _insert_jj_after_git if type -q zoxide zoxide init fish | source end if type -q atuin atuin init fish | source end + if type -q direnv + direnv hook fish | source + end if test -f ~/.config/fish/config.fish.local source ~/.config/fish/config.fish.local @@ -17,7 +21,5 @@ end alias ls="lsd" -fish_add_path $HOME/.webman/bin - set -gx EDITOR nvim diff --git a/dot_config/private_fish/functions/_insert_jj_after_git.fish b/dot_config/private_fish/functions/_insert_jj_after_git.fish new file mode 100644 index 0000000..ed4d2a5 --- /dev/null +++ b/dot_config/private_fish/functions/_insert_jj_after_git.fish @@ -0,0 +1,18 @@ +function _insert_jj_after_git + # Get current items + set -l current_items $tide_left_prompt_items + + # Check if jj already exists + if not contains jj $current_items + # Find git's position + set -l git_pos (contains -i git $current_items) + + if test $git_pos -gt 0 + # Create new list: items before git + git + jj + items after git + set -l new_items $current_items[1..$git_pos] jj $current_items[(math $git_pos + 1)..-1] + + # Update the universal variable + set -U tide_left_prompt_items $new_items + end + end +end diff --git a/dot_config/private_fish/functions/_tide_item_jj.fish b/dot_config/private_fish/functions/_tide_item_jj.fish new file mode 100644 index 0000000..aa1b413 --- /dev/null +++ b/dot_config/private_fish/functions/_tide_item_jj.fish @@ -0,0 +1,33 @@ +function _tide_item_jj + if not command -sq jj; or not jj root --quiet &>/dev/null + return 1 + end + + set jj_status (jj log -r@ -n1 --ignore-working-copy --no-graph --color always -T ' + separate(" ", + bookmarks.map(|x| if( + x.name().substr(0, 10).starts_with(x.name()), + x.name().substr(0, 10), + x.name().substr(0, 9) ++ "…") + ).join(" "), + tags.map(|x| if( + x.name().substr(0, 10).starts_with(x.name()), + x.name().substr(0, 10), + x.name().substr(0, 9) ++ "…") + ).join(" "), + surround("\"","\"", + if( + description.first_line().substr(0, 24).starts_with(description.first_line()), + description.first_line().substr(0, 24), + description.first_line().substr(0, 23) ++ "…" + ) + ), + change_id.shortest(), + commit_id.shortest(), + if(conflict, "conflict"), + if(divergent, "divergent"), + if(hidden, "hidden"), + )' | string trim) + set jj_info $jj_status + _tide_print_item jj $tide_jj_icon' ' "($(string join ', ' $jj_info))" +end diff --git a/run_once_after_install2.sh.tmpl b/run_once_after_install2.sh.tmpl index 5c4d8ae..5908d0c 100644 --- a/run_once_after_install2.sh.tmpl +++ b/run_once_after_install2.sh.tmpl @@ -44,6 +44,8 @@ else echo "Failed to download GeistMono.zip" fi +sudo sh -c "echo $(which fish) >> /etc/shells" + {{- end }} # check if $SHELL is fish already diff --git a/run_onchange_install-packages.sh.tmpl b/run_onchange_install-packages.sh.tmpl index 84507cb..9d99b1e 100644 --- a/run_onchange_install-packages.sh.tmpl +++ b/run_onchange_install-packages.sh.tmpl @@ -26,7 +26,7 @@ sudo apt install -y {{ . | quote }} {{- else if eq .osid "darwin" }} echo "[-] Updating brews [-]" {{ range .packages.darwin.brews -}} -brew install {{ . | quote }} +/opt/homebrew/bin/brew install {{ . | quote }} {{ end -}} {{ end -}}