Creating dotfiles for terminals
dot files for terminals a
This commit is contained in:
31
nushell/carapace.nu
Normal file
31
nushell/carapace.nu
Normal file
@@ -0,0 +1,31 @@
|
||||
$env.PATH = ($env.PATH | split row (char esep) | prepend "/home/sam/.config/carapace/bin")
|
||||
|
||||
def --env get-env [name] { $env | get $name }
|
||||
def --env set-env [name, value] { load-env { $name: $value } }
|
||||
def --env unset-env [name] { hide-env $name }
|
||||
|
||||
let carapace_completer = {|spans|
|
||||
# if the current command is an alias, get it's expansion
|
||||
let expanded_alias = (scope aliases | where name == $spans.0 | $in.0?.expansion?)
|
||||
|
||||
# overwrite
|
||||
let spans = (if $expanded_alias != null {
|
||||
# put the first word of the expanded alias first in the span
|
||||
$spans | skip 1 | prepend ($expanded_alias | split row " " | take 1)
|
||||
} else {
|
||||
$spans | skip 1 | prepend ($spans.0)
|
||||
})
|
||||
|
||||
carapace $spans.0 nushell ...$spans
|
||||
| from json
|
||||
}
|
||||
|
||||
mut current = (($env | default {} config).config | default {} completions)
|
||||
$current.completions = ($current.completions | default {} external)
|
||||
$current.completions.external = ($current.completions.external
|
||||
| default true enable
|
||||
# backwards compatible workaround for default, see nushell #15654
|
||||
| upsert completer { if $in == null { $carapace_completer } else { $in } })
|
||||
|
||||
$env.config = $current
|
||||
|
||||
Reference in New Issue
Block a user