jj config incl. fish prompt

This commit is contained in:
sloane 2024-07-18 12:23:05 -04:00
parent 45db206f9b
commit aa3bb5ccb8
No known key found for this signature in database
4 changed files with 105 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1 +0,0 @@
/nix/store/rpzzkvjfhnqj9qi93xd05glh3vw5d2zs-home-manager-files/.jjconfig.toml

17
.jjconfig.toml Normal file
View file

@ -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"