Compare commits

..

6 commits

Author SHA1 Message Date
bfecbdcd59
nu: Add space prefix to keybind commands to prevent history adding
To prevent adding any of the keyboard-binding driven commands to the
user's command history, we simply prefix all of them with a single
space.
2025-11-14 14:15:04 +01:00
b305be8ad0
nu: Add partial auto suggestion completion
The suggested history completion on the reedline (i.e. fish-like
autosuggestion) can be fully completed with the `l` key in vi cmd mode.

This change adds the ability to complete the suggestion partially by
completing the current word using `e`. If no history suggestion exists
it moves to the end of the current word as usual.

This mimics the partial completion I have set up in zsh with the help of
the `zsh-autosuggestions` plugin.
2025-11-14 14:15:04 +01:00
26e8cc3ccc
nu: Add job control shortcuts
Using <c-z> when a process is running backgrounds it (default behavior)
using the new nushell job control system (since v0.103).
This change also lets you re-foreground the backgrounded program with
the same <c-z> key mapping.

Additionally we add the `fg` alias which does the same and thus mimics
the fg command of other shells like zsh.
2025-11-14 14:15:03 +01:00
37cc1a3d83
nu: Enable transient prompt
Enabled transient prompt for nushell so we only display the line
character and attempt to display command durations for past prompts.

Not sure if command duration is working correctly. If not, might have to
revert this change.
2025-11-14 14:15:03 +01:00
ae5470a5d8
nu: Add fuzzy tab completion, remove nvim hardcoding
Removed the buffer editor hardcoding to 'nvim', should use the EDITOR
env var instead.

Added the (currently undocumented?) config option to enable fuzzy
completion matching - essentially enables exactly the behavior the
'fzf-tab-complete' plugin does for zsh, only natively in the nushell
program.

See: https://github.com/nushell/nushell/issues/1275#issuecomment-2964573062
2025-11-14 14:15:02 +01:00
07d36e3132
starship: Restyle continuation prompt
When entering multiline commands, display a slightly more pronounced line
prefix so we can recognize faster that it expects more input.
2025-11-14 14:15:01 +01:00
2 changed files with 44 additions and 9 deletions

View file

@ -9,13 +9,17 @@
#
# This file is loaded after env.nu and before login.nu
#
$env.config.show_banner = false # TODO: FOR TESTING PURPOSES
$env.config.show_banner = false
$env.config.edit_mode = "vi"
$env.config.buffer_editor = "nvim"
# Enable same behavior as fzf-tab-complete for zsh
$env.config.completions.algorithm = "fuzzy"
$env.PROMPT_INDICATOR = ""
$env.PROMPT_MULTILINE_INDICATOR = "::: "
$env.PROMPT_MULTILINE_INDICATOR = "::: " # overwritten by starship
# enable transient prompt with starship
$env.TRANSIENT_PROMPT_COMMAND = ^starship module character
$env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| ^starship module cmd_duration }
# FIXME: Disabled for now to use starship prompts instead
# but still very buggy. See:
@ -28,7 +32,7 @@ $env.PROMPT_INDICATOR_VI_NORMAL = ""
# Temporary workaround
$env.config.cursor_shape.vi_insert = "line"
$env.config.cursor_shape.vi_normal = "block"
# TODO: Currently recommended starship install. Change when it changes.
# load starship prompt
mkdir ($nu.data-dir | path join "vendor/autoload")
starship init nu | save -f ($nu.data-dir | path join "vendor/autoload/starship.nu")
# load atuin history
@ -51,6 +55,7 @@ $env.config.keybindings = [
{send: Enter}
]
}
# reedline edits
{
name: insert_last_token
modifier: alt
@ -76,10 +81,23 @@ $env.config.keybindings = [
keycode: char_s
mode: [emacs vi_insert vi_normal]
event: {
send: executehostcommand
cmd: "let cmd = (commandline); commandline edit (if $cmd starts-with sudo { $cmd | str replace -r '^sudo ' '' } else { 'sudo ' ++ $cmd });"
send: ExecuteHostCommand
cmd: " let cmd = (commandline); commandline edit (if $cmd starts-with sudo { $cmd | str replace -r '^sudo ' '' } else { 'sudo ' ++ $cmd });"
}
}
{
name: partial_history_complete
modifier: None
keycode: char_e
mode: [vi_normal]
event: {
until: [
{ send: HistoryHintWordComplete }
{ edit: MoveWordRight }
]
}
}
# file menus
{
name: run_zoxide
modifier: alt
@ -87,7 +105,7 @@ $env.config.keybindings = [
mode: ["emacs", "vi_normal", "vi_insert"]
event: {
send: executehostcommand
cmd: "zoxide query --interactive"
cmd: " zoxide query --interactive"
}
}
{
@ -97,7 +115,7 @@ $env.config.keybindings = [
mode: [ "vi_normal"]
event: {
send: executehostcommand
cmd: "zoxide query --interactive"
cmd: " zoxide query --interactive"
}
}
{
@ -107,7 +125,8 @@ $env.config.keybindings = [
mode: ["emacs", "vi_normal", "vi_insert"]
event: {
send: executehostcommand
cmd: "
# intentional eol space to prevent adding cmd to history
cmd: "
let fzf_ctrl_t_command = \$\"fd --type file --hidden | fzf --preview 'bat --color=always --style=full --line-range=:500 {}' \";
let result = nu -l -i -c $fzf_ctrl_t_command;
commandline edit --append $result;
@ -115,6 +134,17 @@ $env.config.keybindings = [
"
}
}
# job control
{
name: unfreeze_job
modifier: control
keycode: char_z
mode: ["emacs", "vi_normal", "vi_insert"]
event: {
send: executehostcommand
cmd: "job unfreeze"
}
}
]
alias l = ls
@ -127,3 +157,6 @@ def --env mcd [path: path] {
}
alias v = nvim
# requires minimum nushell: 0.103 for job control
alias fg = job unfreeze

View file

@ -26,6 +26,8 @@ $typst\
$package
"""
continuation_prompt = "[:::](bright-black) "
[directory]
style = "blue"
fish_style_pwd_dir_length = 1