From de6547851a5bfc6835a86cde694352e851beee1d Mon Sep 17 00:00:00 2001 From: Daniel Lundin Date: Mon, 13 Jan 2025 18:40:36 +0100 Subject: [PATCH] fish: remove unused config --- files/config/fish/go-task.fish | 37 ---- files/config/fish/jj.fish | 338 --------------------------------- home/common/fish.nix | 67 ++++--- 3 files changed, 32 insertions(+), 410 deletions(-) delete mode 100644 files/config/fish/go-task.fish delete mode 100644 files/config/fish/jj.fish diff --git a/files/config/fish/go-task.fish b/files/config/fish/go-task.fish deleted file mode 100644 index 6c7e2cf..0000000 --- a/files/config/fish/go-task.fish +++ /dev/null @@ -1,37 +0,0 @@ -set GO_TASK_PROGNAME task - -function __task_get_tasks --description "Prints all available tasks with their description" - # Read the list of tasks (and potential errors) - $GO_TASK_PROGNAME --list-all 2>&1 | read -lz rawOutput - - # Return on non-zero exit code (for cases when there is no Taskfile found or etc.) - if test $status -ne 0 - return - end - - # Grab names and descriptions (if any) of the tasks - set -l output (echo $rawOutput | sed -e '1d; s/\* \(.*\):\s*\(.*\)\s*(aliases.*/\1\t\2/' -e 's/\* \(.*\):\s*\(.*\)/\1\t\2/'| string split0) - if test $output - echo $output - end -end - -complete -c $GO_TASK_PROGNAME -d 'Runs the specified task(s). Falls back to the "default" task if no task name was specified, or lists all tasks if an unknown task name was - specified.' -xa "(__task_get_tasks)" - -complete -c $GO_TASK_PROGNAME -s c -l color -d 'colored output (default true)' -complete -c $GO_TASK_PROGNAME -s d -l dir -d 'sets directory of execution' -complete -c $GO_TASK_PROGNAME -l dry -d 'compiles and prints tasks in the order that they would be run, without executing them' -complete -c $GO_TASK_PROGNAME -s f -l force -d 'forces execution even when the task is up-to-date' -complete -c $GO_TASK_PROGNAME -s h -l help -d 'shows Task usage' -complete -c $GO_TASK_PROGNAME -s i -l init -d 'creates a new Taskfile.yml in the current folder' -complete -c $GO_TASK_PROGNAME -s l -l list -d 'lists tasks with description of current Taskfile' -complete -c $GO_TASK_PROGNAME -s o -l output -d 'sets output style: [interleaved|group|prefixed]' -xa "interleaved group prefixed" -complete -c $GO_TASK_PROGNAME -s p -l parallel -d 'executes tasks provided on command line in parallel' -complete -c $GO_TASK_PROGNAME -s s -l silent -d 'disables echoing' -complete -c $GO_TASK_PROGNAME -l status -d 'exits with non-zero exit code if any of the given tasks is not up-to-date' -complete -c $GO_TASK_PROGNAME -l summary -d 'show summary about a task' -complete -c $GO_TASK_PROGNAME -s t -l taskfile -d 'choose which Taskfile to run. Defaults to "Taskfile.yml"' -complete -c $GO_TASK_PROGNAME -s v -l verbose -d 'enables verbose mode' -complete -c $GO_TASK_PROGNAME -l version -d 'show Task version' -complete -c $GO_TASK_PROGNAME -s w -l watch -d 'enables watch of the given task' diff --git a/files/config/fish/jj.fish b/files/config/fish/jj.fish deleted file mode 100644 index 9a6257e..0000000 --- a/files/config/fish/jj.fish +++ /dev/null @@ -1,338 +0,0 @@ -# TODO: passthru other args? E.g.. --at-operation, --repository -function __jj - command jj --ignore-working-copy --color=never --quiet $argv 2>/dev/null -end - -# Aliases -# Based on https://github.com/fish-shell/fish-shell/blob/cd71359c42f633d9d71a63591ae16d150407a2b2/share/completions/git.fish#L625. -# -# Aliases are stored in global variables. -# `__jj_aliases` is a list of all aliases and `__jj_alias_$alias` is the command line for the alias. -function __jj_add_alias - set -l alias $argv[1] - set -l alias_escaped (string escape --style=var -- $alias) - set -g __jj_alias_$alias_escaped $argv - set --append -g __jj_aliases $alias -end - -__jj config list aliases -T 'concat(name, "\t", value, "\n")' --include-defaults | while read -l config_alias - set -l parsed (string match --regex '^aliases\.(.+)\t(.*)$' --groups-only -- $config_alias) - set -l alias $parsed[1] - set -l command $parsed[2] - set -l args $alias - # Replace wrapping `[]` if any - set -l command (string replace -r --all '^\[|]$' "" -- $command) - while test (string length -- $command) -gt 0 - set -l parsed (string match -r '^"((?:\\\"|[^"])*?)"(?:,\s)?(.*)$' --groups-only -- $command) - set --append args $parsed[1] - set command $parsed[2] - end - __jj_add_alias $args -end - -__jj_add_alias ci commit -__jj_add_alias desc describe -__jj_add_alias op operation -__jj_add_alias st status - -# Resolve aliases that call another alias. -for alias in $__jj_aliases - set -l handled $alias - - while true - set -l alias_escaped (string escape --style=var -- $alias) - set -l alias_varname __jj_alias_$alias_escaped - set -l aliased_command $$alias_varname[1][2] - set -l aliased_escaped (string escape --style=var -- $aliased_command) - set -l aliased_varname __jj_alias_$aliased_escaped - set -q $aliased_varname - or break - - # Prevent infinite recursion - contains $aliased_escaped $handled - and break - - # Expand alias in cmdline - set -l aliased_cmdline $$aliased_varname[1][2..-1] - set --append aliased_cmdline $$alias_varname[1][3..-1] - set -g $alias_varname $$alias_varname[1][1] $aliased_cmdline - set --append handled $aliased_escaped - end -end - -function __jj_aliases_with_descriptions - for alias in $__jj_aliases - set -l alias_escaped (string escape --style=var -- $alias) - set -l alias_varname __jj_alias_$alias_escaped - set -l aliased_cmdline (string join " " -- $$alias_varname[1][2..-1] | string replace -r --all '\\\"' '"') - printf "%s\talias: %s\n" $alias $aliased_cmdline - end -end - -# Based on https://github.com/fish-shell/fish-shell/blob/2d4e42ee93327b9cfd554a0d809f85e3d371e70e/share/functions/__fish_seen_subcommand_from.fish. -# Test to see if we've seen a subcommand from a list. -# This logic may seem backwards, but the commandline will often be much shorter than the list. -function __jj_seen_subcommand_from - set -l cmd (commandline -opc) - set -e cmd[1] - - # Check command line arguments first. - for i in $cmd - if contains -- $i $argv - return 0 - end - end - - # Check aliases. - set -l alias $cmd[1] - set -l alias_escaped (string escape --style=var -- $alias) - set -l varname __jj_alias_$alias_escaped - set -q $varname - or return 1 - - for i in $$varname[1][2..-1] - if contains -- $i $argv - return 0 - end - end - - return 1 -end - -function __jj_changes - __jj log --no-graph --limit 1000 -r $argv[1] \ - -T 'separate("\t", change_id.shortest(), if(description, description.first_line(), "(no description set)")) ++ "\n"' -end - -function __jj_bookmarks - set -f filter $argv[1] - if string length --quiet -- $argv[2] - __jj bookmark list --all-remotes -r "$argv[2]" \ - -T "if($filter, name ++ if(remote, \"@\" ++ remote) ++ \"\t\" ++ if(normal_target, normal_target.change_id().shortest() ++ \": \" ++ if(normal_target.description(), normal_target.description().first_line(), \"(no description set)\"), \"(conflicted bookmark)\") ++ \"\n\")" - else - __jj bookmark list --all-remotes \ - -T "if($filter, name ++ if(remote, \"@\" ++ remote) ++ \"\t\" ++ if(normal_target, normal_target.change_id().shortest() ++ \": \" ++ if(normal_target.description(), normal_target.description().first_line(), \"(no description set)\"), \"(conflicted bookmark)\") ++ \"\n\")" - end -end - -function __jj_all_bookmarks - __jj_bookmarks '!remote || !remote.starts_with("git")' $argv[1] -end - -function __jj_local_bookmarks - __jj_bookmarks '!remote' '' -end - -function __jj_remote_bookmarks - __jj_bookmarks 'remote && !remote.starts_with("git")' '' -end - -function __jj_all_changes - if string length --quiet -- $argv[1] - set -f REV $argv[1] - else - set -f REV "all()" - end - __jj_changes $REV - __jj_all_bookmarks $REV -end - -function __jj_mutable_changes - set -f REV "mutable()" - __jj_changes $REV - __jj_all_bookmarks $REV -end - -function __jj_revision_modified_files - if test $argv[1] = "@" - set -f suffix "" - else - set -l change_id (__jj log --no-graph --limit 1 -T 'change_id.shortest()') - set -f suffix " in $change_id" - end - - __jj diff -r $argv[1] --summary | while read -l line - set -l file (string split " " -m 1 -- $line) - switch $file[1] - case M - set -f change Modified - case D - set -f change Deleted - case A - set -f change Added - end - printf "%s\t%s%s\n" $file[2] $change $suffix - end -end - -function __jj_remotes - __jj git remote list | while read -l remote - printf "%s\t%s\n" (string split " " -m 1 -- $remote) - end -end - -function __jj_operations - __jj operation log --no-graph --limit 1000 -T 'separate("\t", id.short(), description) ++ "\n"' -end - -function __jj_parse_revision - set -l cmd (commandline -opc) - set -e cmd[1] - set -l return_next false - set -l return_value 1 - - # Check aliases. - set -l alias $cmd[1] - set -l alias_escaped (string escape --style=var -- $alias) - set -l varname __jj_alias_$alias_escaped - - if set -q $varname - set cmd $$varname[1][2..-1] $cmd[2..-1] - end - - # Check command line arguments first. - for i in $cmd - if $return_next - echo $i - set return_value 0 - else if contains -- $i -r --revision --from - set return_next true - else - set -l match (string match --regex '^(?:-r=?|--revision=|--from=)(.+)\s*$' --groups-only -- $i) - if set -q match[1] - echo $match[1] - set return_value 0 - end - end - end - - return $return_value -end - -function __jj_revision_files - set -l description (__jj log --no-graph --limit 1 -r $argv[1] -T 'change_id.shortest() ++ ": " ++ coalesce(description.first_line().substr(0, 30), "(no description set)")') - __jj file list -r $argv[1] | while read -l file - printf "%s\t%s\n" $file $description - end -end - -function __jj_revision_conflicted_files - __jj resolve --list -r $argv[1] | while read -l line - set -l file (string split " " -m 1 -- $line) - printf "%s\t%s\n" $file[1] $file[2] - end -end - -function __jj_parse_revision_files - set -l rev (__jj_parse_revision) - if test $status -eq 1 - set rev "@" - end - __jj_revision_files $rev -end - -function __jj_parse_revision_conflicted_files - set -l rev (__jj_parse_revision) - if test $status -eq 1 - set rev "@" - end - __jj_revision_conflicted_files $rev -end - -function __jj_parse_revision_files_or_wc_modified_files - set -l revs (__jj_parse_revision) - if test $status -eq 1 - __jj_revision_modified_files "@" - else - for rev in $revs - __jj_revision_files $rev - end - end -end - -function __jj_parse_revision_modified_files_or_wc_modified_files - set -l revs (__jj_parse_revision) - if test $status -eq 1 - __jj_revision_modified_files "@" - else - for rev in $revs - __jj_revision_modified_files $rev - end - end -end - -# Aliases. -complete -f -c jj -n __fish_use_subcommand -a '(__jj_aliases_with_descriptions)' - -# Files. -complete -f -c jj -n '__jj_seen_subcommand_from file; and __jj_seen_subcommand_from show' -ka '(__jj_parse_revision_files)' -complete -f -c jj -n '__jj_seen_subcommand_from file; and __jj_seen_subcommand_from chmod' -ka '(__jj_parse_revision_files)' -complete -f -c jj -n '__jj_seen_subcommand_from commit' -ka '(__jj_revision_modified_files "@")' -complete -c jj -n '__jj_seen_subcommand_from diff' -ka '(__jj_parse_revision_files_or_wc_modified_files)' -complete -c jj -n '__jj_seen_subcommand_from interdiff' -ka '(__jj_parse_revision_files)' -complete -f -c jj -n '__jj_seen_subcommand_from resolve' -ka '(__jj_parse_revision_conflicted_files)' -complete -f -c jj -n '__jj_seen_subcommand_from restore' -ka '(__jj_parse_revision_files_or_wc_modified_files)' -complete -f -c jj -n '__jj_seen_subcommand_from split' -ka '(__jj_parse_revision_modified_files_or_wc_modified_files)' -complete -f -c jj -n '__jj_seen_subcommand_from squash' -ka '(__jj_parse_revision_modified_files_or_wc_modified_files)' -complete -f -c jj -n '__jj_seen_subcommand_from untrack' -ka '(__jj_parse_revision_files_or_wc_modified_files)' - -# Revisions. -complete -f -c jj -n '__jj_seen_subcommand_from abandon' -ka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from backout' -s r -l revision -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from backout' -s d -l destination -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from file; and __jj_seen_subcommand_from show' -s r -l revision -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from chmod' -s r -l revision -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from describe' -ka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from diff' -s r -l revision -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from diff' -l from -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from diff' -l to -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from diffedit' -s r -l revision -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from diffedit' -l from -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from diffedit' -l to -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from duplicate' -ka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from edit' -ka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from file; and __jj_seen_subcommand_from list' -s r -l revision -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from interdiff' -l from -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from interdiff' -l to -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from log' -s r -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from new' -ka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from new' -s A -l after -l insert-after -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from new' -s B -l before -l insert-before -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from obslog' -s r -l revision -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from parallelize' -ka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from rebase' -s r -l revisions -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from rebase' -s s -l source -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from rebase' -s b -l bookmark -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from rebase' -s d -l destination -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from rebase' -s A -l after -l insert-after -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from rebase' -s B -l before -l insert-before -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from resolve' -s r -l revision -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from restore' -l from -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from restore' -l to -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from restore' -s c -l changes-in -rka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from show' -ka '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from split' -s r -l revision -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from squash' -s r -l revision -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from squash' -l from -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from squash' -l to -l into -rka '(__jj_mutable_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from unsquash' -s r -l revision -rka '(__jj_mutable_changes)' - -# Bookmarks -complete -f -c jj -n '__jj_seen_subcommand_from bookmark; and __jj_seen_subcommand_from delete forget rename set d f r s' -ka '(__jj_local_bookmarks)' -complete -f -c jj -n '__jj_seen_subcommand_from bookmark; and __jj_seen_subcommand_from track t' -ka '(__jj_bookmarks "remote && !tracked" "")' -complete -f -c jj -n '__jj_seen_subcommand_from bookmark; and __jj_seen_subcommand_from untrack' -ka '(__jj_bookmarks "remote && tracked && !remote.starts_with(\"git\")" "")' -complete -f -c jj -n '__jj_seen_subcommand_from bookmark; and __jj_seen_subcommand_from create move set c m s' -s r -l revision -kra '(__jj_all_changes)' -complete -f -c jj -n '__jj_seen_subcommand_from bookmark; and __jj_seen_subcommand_from move' -l from -rka '(__jj_changes "all()")' -complete -f -c jj -n '__jj_seen_subcommand_from bookmark; and __jj_seen_subcommand_from move' -l to -rka '(__jj_changes "all()")' - -# Git. -complete -f -c jj -n '__jj_seen_subcommand_from git; and __jj_seen_subcommand_from push' -s c -l change -kra '(__jj_changes "all()")' -complete -f -c jj -n '__jj_seen_subcommand_from git; and __jj_seen_subcommand_from push' -s r -l revisions -kra '(__jj_changes "all()")' -complete -f -c jj -n '__jj_seen_subcommand_from git; and __jj_seen_subcommand_from fetch push' -s b -l bookmark -rka '(__jj_local_bookmarks)' -complete -f -c jj -n '__jj_seen_subcommand_from git; and __jj_seen_subcommand_from fetch push' -l remote -rka '(__jj_remotes)' -complete -f -c jj -n '__jj_seen_subcommand_from git; and __jj_seen_subcommand_from remote; and __jj_seen_subcommand_from remove rename set-url' -ka '(__jj_remotes)' - -# Operations. -complete -f -c jj -l at-op -l at-operation -rka '(__jj_operations)' -complete -f -c jj -n '__jj_seen_subcommand_from undo' -ka '(__jj_operations)' -complete -f -c jj -n '__jj_seen_subcommand_from operation; and __jj_seen_subcommand_from abandon undo restore' -ka '(__jj_operations)' diff --git a/home/common/fish.nix b/home/common/fish.nix index 03cf86f..e5d1c45 100644 --- a/home/common/fish.nix +++ b/home/common/fish.nix @@ -3,7 +3,6 @@ programs.fish = { enable = true; - plugins = [ { name = "transient"; @@ -57,42 +56,42 @@ ''; fish_jj_prompt.body = '' - if not command -sq jj || not jj root --quiet &>/dev/null - return 1 - end + if not command -sq jj || not jj root --quiet &>/dev/null + return 1 + end - jj log --ignore-working-copy --no-graph --color never -r @ -T ' - surround( - " \e[2;3m", - "\e[0m", - separate( - " ", - surround( - "\e[0;2;3m", - "\e[0m", - coalesce( - surround( - "\e[1;2;3m❝", - "❞\e[0m", - if( - description.first_line().substr(0, 80).starts_with(description.first_line()), - description.first_line().substr(0, 80), - description.first_line().substr(0, 79) ++ "…" - ) + jj log --ignore-working-copy --no-graph --color never -r @ -T ' + surround( + " \e[2;3m", + "\e[0m", + separate( + " ", + surround( + "\e[0;2;3m", + "\e[0m", + coalesce( + surround( + "\e[1;2;3m❝", + "❞\e[0m", + if( + description.first_line().substr(0, 80).starts_with(description.first_line()), + description.first_line().substr(0, 80), + description.first_line().substr(0, 79) ++ "…" + ) + ), + "…" ), - "…" ), - ), - surround("\e[0;1;95m ", "\e[0;2;3m", change_id.shortest()), - surround("\e[0;35m󰸕 ", "\e[0m", bookmarks.join("╱")), - surround("\e[0;34m ", "\e[0;2;3m", commit_id.shortest()), - if(conflict, "󰂭"), - if(empty, ""), - if(divergent, ""), - if(hidden, "󰘓"), + surround("\e[0;1;95m ", "\e[0;2;3m", change_id.shortest()), + surround("\e[0;35m󰸕 ", "\e[0m", bookmarks.join("╱")), + surround("\e[0;34m ", "\e[0;2;3m", commit_id.shortest()), + if(conflict, "󰂭"), + if(empty, ""), + if(divergent, ""), + if(hidden, "󰘓"), + ) ) - ) - ' + ' ''; fish_prompt.body = '' @@ -117,8 +116,6 @@ interactiveShellInit = lib.concatStringsSep "\n" [ (builtins.readFile ../../files/config/fish/config.fish) (builtins.readFile ../../files/config/fish/semantic-prompt.fish) - (builtins.readFile ../../files/config/fish/go-task.fish) - (builtins.readFile ../../files/config/fish/jj.fish) (builtins.readFile ../../files/config/fish/vcs.fish) ];