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.
161 lines
4.4 KiB
Text
161 lines
4.4 KiB
Text
# config.nu
|
|
#
|
|
# Installed by:
|
|
# version = "0.102.0"
|
|
#
|
|
# This file is used to override default Nushell settings, define
|
|
# (or import) custom commands, or run any other startup tasks.
|
|
# See https://www.nushell.sh/book/configuration.html
|
|
#
|
|
# This file is loaded after env.nu and before login.nu
|
|
#
|
|
$env.config.show_banner = false
|
|
|
|
$env.config.edit_mode = "vi"
|
|
# Enable same behavior as fzf-tab-complete for zsh
|
|
$env.config.completions.algorithm = "fuzzy"
|
|
|
|
$env.PROMPT_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:
|
|
# https://github.com/starship/starship/issues/5423 and
|
|
# https://github.com/nushell/nushell/issues/14650
|
|
# $env.PROMPT_INDICATOR_VI_INSERT = ": "
|
|
# $env.PROMPT_INDICATOR_VI_NORMAL = "〉"
|
|
$env.PROMPT_INDICATOR_VI_INSERT = ""
|
|
$env.PROMPT_INDICATOR_VI_NORMAL = ""
|
|
# Temporary workaround
|
|
$env.config.cursor_shape.vi_insert = "line"
|
|
$env.config.cursor_shape.vi_normal = "block"
|
|
# 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
|
|
atuin init nu | save -f ($nu.data-dir | path join "vendor/autoload/atuin.nu")
|
|
# load zoxide bookmarks
|
|
zoxide init nushell | save -f ($nu.data-dir | path join "vendor/autoload/zoxide.nu")
|
|
# load carapace completions
|
|
source ~/.cache/carapace/init.nu
|
|
|
|
# keybinds
|
|
$env.config.keybindings = [
|
|
{ modifier: control keycode: char_o mode: [emacs, vi_normal, vi_insert] event: null },
|
|
{
|
|
name: clear_screen
|
|
modifier: alt
|
|
keycode: char_l
|
|
mode: ["emacs", "vi_normal", "vi_insert"]
|
|
event: [
|
|
{edit: Clear}
|
|
{send: Enter}
|
|
]
|
|
}
|
|
# reedline edits
|
|
{
|
|
name: insert_last_token
|
|
modifier: alt
|
|
keycode: char_.
|
|
mode: ["emacs", "vi_normal", "vi_insert"]
|
|
event: [
|
|
{ edit: InsertString, value: "!$" }
|
|
{ send: Enter }
|
|
]
|
|
}
|
|
{
|
|
name: open_editor
|
|
modifier: control
|
|
keycode: char_e
|
|
mode: ["emacs", "vi_normal", "vi_insert"]
|
|
event: {
|
|
send: OpenEditor
|
|
}
|
|
}
|
|
{
|
|
name: toggle_sudo
|
|
modifier: alt
|
|
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 });"
|
|
}
|
|
}
|
|
{
|
|
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
|
|
keycode: char_c
|
|
mode: ["emacs", "vi_normal", "vi_insert"]
|
|
event: {
|
|
send: executehostcommand
|
|
cmd: "zoxide query --interactive"
|
|
}
|
|
}
|
|
{
|
|
name: run_zoxide_vicmd
|
|
modifier: shift
|
|
keycode: char_c
|
|
mode: [ "vi_normal"]
|
|
event: {
|
|
send: executehostcommand
|
|
cmd: "zoxide query --interactive"
|
|
}
|
|
}
|
|
{
|
|
name: insert_file_fzf
|
|
modifier: control
|
|
keycode: char_t
|
|
mode: ["emacs", "vi_normal", "vi_insert"]
|
|
event: {
|
|
send: executehostcommand
|
|
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;
|
|
commandline set-cursor --end
|
|
"
|
|
}
|
|
}
|
|
# 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
|
|
alias cl = clear
|
|
|
|
alias md = mkdir
|
|
def --env mcd [path: path] {
|
|
mkdir $path
|
|
cd $path
|
|
}
|
|
|
|
alias v = nvim
|
|
|
|
# requires minimum nushell: 0.103 for job control
|
|
alias fg = job unfreeze
|