From aa3bb5ccb89974135e5a95f7cced63908d114299 Mon Sep 17 00:00:00 2001 From: sloane <1699281+sloanelybutsurely@users.noreply.github.com> Date: Thu, 18 Jul 2024 12:23:05 -0400 Subject: [PATCH] jj config incl. fish prompt --- .config/fish/functions/fish_jj_prompt.fish | 45 +++++++++++++++++++++ .config/fish/functions/fish_prompt.fish | 31 ++++++++++++++ .config/fish/functions/fish_vcs_prompt.fish | 12 ++++++ .jjconfig.toml | 18 ++++++++- 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 .config/fish/functions/fish_jj_prompt.fish create mode 100644 .config/fish/functions/fish_prompt.fish create mode 100644 .config/fish/functions/fish_vcs_prompt.fish mode change 120000 => 100644 .jjconfig.toml diff --git a/.config/fish/functions/fish_jj_prompt.fish b/.config/fish/functions/fish_jj_prompt.fish new file mode 100644 index 0000000..41caaa3 --- /dev/null +++ b/.config/fish/functions/fish_jj_prompt.fish @@ -0,0 +1,45 @@ +# https://gist.github.com/hroi/d0dc0e95221af858ee129fd66251897e/ +# Place me in ~/.config/fish/functions +# Then add me to `fish_vcs_prompt`: `funced fish_vcs_prompt` + +function fish_jj_prompt --description 'Write out the jj prompt' + # Is jj installed? + if not command -sq jj + return 1 + end + + # Are we in a jj repo? + if not jj root --quiet &>/dev/null + return 1 + end + + # Generate prompt + jj log --ignore-working-copy --no-graph --color always -r @ -T ' + surround( + " (", + ")", + separate( + " ", + branches.join(", "), + coalesce( + 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) ++ "…" + ) + ), + "(no description set)" + ), + change_id.shortest(), + commit_id.shortest(), + if(conflict, "(conflict)"), + if(empty, "(empty)"), + if(divergent, "(divergent)"), + if(hidden, "(hidden)"), + ) + ) + ' +end diff --git a/.config/fish/functions/fish_prompt.fish b/.config/fish/functions/fish_prompt.fish new file mode 100644 index 0000000..c047a5f --- /dev/null +++ b/.config/fish/functions/fish_prompt.fish @@ -0,0 +1,31 @@ +function fish_prompt --description 'Write out the prompt' + set -l last_pipestatus $pipestatus + set -lx __fish_last_status $status # Export for __fish_print_pipestatus. + set -l normal (set_color normal) + set -q fish_color_status + or set -g fish_color_status red + + # Color the prompt differently when we're root + set -l color_cwd $fish_color_cwd + set -l suffix '>' + if functions -q fish_is_root_user; and fish_is_root_user + if set -q fish_color_cwd_root + set color_cwd $fish_color_cwd_root + end + set suffix '#' + end + + # Write pipestatus + # If the status was carried over (if no command is issued or if `set` leaves the status untouched), don't bold it. + set -l bold_flag --bold + set -q __fish_prompt_status_generation; or set -g __fish_prompt_status_generation $status_generation + if test $__fish_prompt_status_generation = $status_generation + set bold_flag + end + set __fish_prompt_status_generation $status_generation + set -l status_color (set_color $fish_color_status) + set -l statusb_color (set_color $bold_flag $fish_color_status) + set -l prompt_status (__fish_print_pipestatus "[" "]" "|" "$status_color" "$statusb_color" $last_pipestatus) + + echo -n -s ' ' (set_color $color_cwd) (prompt_pwd) $normal (fish_vcs_prompt) $normal " "$prompt_status $suffix " " +end diff --git a/.config/fish/functions/fish_vcs_prompt.fish b/.config/fish/functions/fish_vcs_prompt.fish new file mode 100644 index 0000000..216244c --- /dev/null +++ b/.config/fish/functions/fish_vcs_prompt.fish @@ -0,0 +1,12 @@ +function fish_vcs_prompt --description "Print all vcs prompts" + # If a prompt succeeded, we assume that it's printed the correct info. + # This is so we don't try svn if git already worked. + fish_jj_prompt $argv + or fish_git_prompt $argv + or fish_hg_prompt $argv + or fish_fossil_prompt $argv + # The svn prompt is disabled by default because it's quite slow on common svn repositories. + # To enable it uncomment it. + # You can also only use it in specific directories by checking $PWD. + # or fish_svn_prompt +end diff --git a/.jjconfig.toml b/.jjconfig.toml deleted file mode 120000 index 095f701..0000000 --- a/.jjconfig.toml +++ /dev/null @@ -1 +0,0 @@ -/nix/store/rpzzkvjfhnqj9qi93xd05glh3vw5d2zs-home-manager-files/.jjconfig.toml \ No newline at end of file diff --git a/.jjconfig.toml b/.jjconfig.toml new file mode 100644 index 0000000..5d3b82d --- /dev/null +++ b/.jjconfig.toml @@ -0,0 +1,17 @@ +[core] +fsmonitor = "watchman" + +[signing] +backend = "ssh" +key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAID0TH2GezEx8+zlKBqUb7rBsbmghnd1u4nX6YpQr28Zw" +sign-all = true + +[signing.backends.ssh] +program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign" + +[ui] +paginate = "never" + +[user] +email = "1699281+sloanelybutsurely@users.noreply.github.com" +name = "sloane"