10
Fish shell
Winter edited this page 2025-04-09 14:50:56 -04:00

Completions

For setting up completions, see https://jj-vcs.github.io/jj/latest/install-and-setup/#command-line-completion. The new (dynamic) completions are recommended; they work very well with Fish.

Prompt

Update/Note: As of fish 4.1.0 (unreleased as of writing), a basic jj prompt is shipped with fish out of the box: https://github.com/fish-shell/fish-shell/blob/master/share/functions/fish_jj_prompt.fish. You may still be interested in replacing the default fish_jj_prompt function with something more elaborate.


There are multiple prompts that people have written for fish, each with their own benefits. They slot into the existing fish_vcs_prompt function right before fish_git_prompt, so that colocated jj repositories will print the jj prompt.

Community members have written some example prompts:

You can change fish functions with the funced command, which will bring up the current source of that function in your configured editor. First, you should add the fish_jj_prompt function:

> funced fish_jj_prompt
> # (copy in the code from one of the links)
> funcsave fish_jj_prompt

Then, you can edit the fish_vcs_prompt the same way; you want to add a line calling fish_jj_prompt:

 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_git_prompt $argv
+    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