Custom commands can be defined in the custom_commands
section of the configuration:
[custom_commands]
"show diff" = { key = ["U"], args = ["diff", "-r", "$change_id", "--color", "always"], show = "diff" }
"show oplog diff" = { key = ["ctrl+o"], args = ["op", "show", "$operation_id", "--color", "always"], show = "diff" }
"resolve vscode" = { key = ["R"], args = ["resolve", "--tool", "vscode"], show = "interactive" }
"new main" = { args = ["new", "main"] }
"tug" = { key = ["ctrl+t"], args = ["bookmark", "move", "--from", "closest_bookmark($change_id)", "--to", "closest_pushable($change_id)"] }
Custom commands can have placeholder arguments like $change_id
, $operation_id
, $file
, and $revset
.
Custom commands can also change the revset. For example, the following custom command will filter the view to only show descendants of the selected revision:
[custom_commands]
"show after revisions" = { key = ["M"], revset = "::$change_id" }
There is also a show
argument which you can set it to be:
none
(default); command will run as is and will only be displayed in the status bar.diff
: the output of the command will be displayed in the diff viewer.interactive
: the command run in interactive mode similar todiffedit
,split
,commit
etc.
Custom commands menu can be opened by pressing x
key. Each custom command can have a dedicated optional custom key binding which you can use to invoke it without having to open the custom commands menu.
Custom command window is context aware so it won't display the commands that have place holder but not applicable to the selected item.
Loading jj aliases as custom_commands. (idea from #211)
You can use the following to import all your aliases as custom commands.
echo "[custom_commands]" >> $JJUI_CONFIG_DIR/config.toml
jj config list aliases -T '"\"" ++ name ++ "\" = { args = [ \"" ++ name ++ "\" ] }\n"' --no-pager |\
sed -e 's/aliases.//g' |\
tee -a $JJUI_CONFIG_DIR/config.toml