diff --git a/manjaro.sh b/manjaro.sh index 2f6732f..f5430e3 100755 --- a/manjaro.sh +++ b/manjaro.sh @@ -25,8 +25,7 @@ yay -S wezterm nushell urxvt-resize-font chsh -s /usr/bin/nu # nushell -yay -S oh-my-posh argc -git clone https://github.com/sigoden/argc-completions.git ~/.local/share/argc-completions/ +yay -S oh-my-posh carapace-bin oh-my-posh init nu --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/refs/heads/main/themes/peru.omp.json # code diff --git a/nushell/config.nu b/nushell/config.nu index 8fb7f8b..93d17cb 100644 --- a/nushell/config.nu +++ b/nushell/config.nu @@ -92,9 +92,27 @@ def monitor [ source ~/.oh-my-posh.nu -# argc-completions -$env.ARGC_COMPLETIONS_ROOT = '/home/hjalmarlucius/.local/share/argc-completions' -$env.ARGC_COMPLETIONS_PATH = ($env.ARGC_COMPLETIONS_ROOT + '/completions/linux:' + $env.ARGC_COMPLETIONS_ROOT + '/completions') -$env.PATH = ($env.PATH | prepend ($env.ARGC_COMPLETIONS_ROOT + '/bin')) -argc --argc-completions nushell | save -f '/home/hjalmarlucius/.local/share/argc-completions/tmp/argc-completions.nu' -source '/home/hjalmarlucius/.local/share/argc-completions/tmp/argc-completions.nu' +let carapace_completer = {|spans| + carapace $spans.0 nushell ...$spans | from json + # carapace doesn't give completions if you don't give it any additional + # args + mut spans = $spans + if ($spans | is-empty) { + $spans = [""] + } + + carapace $spans.0 nushell ...$spans | from json + # sort by color + | sort-by { + let fg = $in | get -i style.fg + let attr = $in | get -i style.attr + + # the ~ there to make "empty" results appear at the end + $"($fg)~($attr)" + } +} +$env.config.completions.external = { + enable: true + max_results: 100 + completer: $carapace_completer +}