aboutsummaryrefslogtreecommitdiff
path: root/dot_config/nushell/autoload
diff options
context:
space:
mode:
authortwells46 <173561638+twells46@users.noreply.github.com>2025-12-31 13:28:05 -0600
committertwells46 <173561638+twells46@users.noreply.github.com>2025-12-31 13:28:05 -0600
commit2140ab51deed88e90eafebf9520fa5f9995dc7c9 (patch)
tree03cf1dcd2900495c1efb79aaa85f3254ecd5fb87 /dot_config/nushell/autoload
parentff8f50638e4b17a9d7cc88d2f0d9560b7effce39 (diff)
Migrate from stow
Diffstat (limited to 'dot_config/nushell/autoload')
-rw-r--r--dot_config/nushell/autoload/01_carapace.nu3
-rw-r--r--dot_config/nushell/autoload/02_carapace.nu1
-rw-r--r--dot_config/nushell/autoload/completer.nu56
-rw-r--r--dot_config/nushell/autoload/lfcd.nu4
4 files changed, 64 insertions, 0 deletions
diff --git a/dot_config/nushell/autoload/01_carapace.nu b/dot_config/nushell/autoload/01_carapace.nu
new file mode 100644
index 0000000..42d9073
--- /dev/null
+++ b/dot_config/nushell/autoload/01_carapace.nu
@@ -0,0 +1,3 @@
+$env.CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense' # optional
+mkdir $"($nu.cache-dir)"
+carapace _carapace nushell | save --force $"($nu.cache-dir)/carapace.nu"
diff --git a/dot_config/nushell/autoload/02_carapace.nu b/dot_config/nushell/autoload/02_carapace.nu
new file mode 100644
index 0000000..b0ceba6
--- /dev/null
+++ b/dot_config/nushell/autoload/02_carapace.nu
@@ -0,0 +1 @@
+source $"($nu.cache-dir)/carapace.nu"
diff --git a/dot_config/nushell/autoload/completer.nu b/dot_config/nushell/autoload/completer.nu
new file mode 100644
index 0000000..910305e
--- /dev/null
+++ b/dot_config/nushell/autoload/completer.nu
@@ -0,0 +1,56 @@
+#let fish_completer = {|spans|
+# fish --command $"complete '--do-complete=($spans | str replace --all "'" "\\'" | str join ' ')'"
+# | from tsv --flexible --noheaders --no-infer
+# | rename value description
+# | update value {|row|
+# let value = $row.value
+# let need_quote = ['\' ',' '[' ']' '(' ')' ' ' '\t' "'" '"' "`"] | any {$in in $value}
+# if ($need_quote and ($value | path exists)) {
+# let expanded_path = if ($value starts-with ~) {$value | path expand --no-symlink} else {$value}
+# $'"($expanded_path | str replace --all "\"" "\\\"")"'
+# } else {$value}
+# }
+#}
+#
+#
+#let carapace_completer = {|spans: list<string>|
+# carapace $spans.0 nushell ...$spans
+# | from json
+# | if ($in | default [] | any {|| $in.display | str starts-with "ERR"}) { null } else { $in }
+#}
+#
+## This completer will use carapace by default
+#let external_completer = {|spans|
+# let expanded_alias = scope aliases
+# | where name == $spans.0
+# | get -o 0.expansion
+#
+# let spans = if $expanded_alias != null {
+# $spans
+# | skip 1
+# | prepend ($expanded_alias | split row ' ' | take 1)
+# } else {
+# $spans
+# }
+#
+# match $spans.0 {
+# # carapace completions are incorrect for nu
+# nu => $fish_completer
+# # fish completes commits and branch names in a nicer way
+# git => $fish_completer
+# # carapace doesn't have completions for asdf
+# asdf => $fish_completer
+# _ => $carapace_completer
+# } | do $in $spans
+#}
+#
+#$env.config = {
+# # ...
+# completions: {
+# external: {
+# enable: true
+# completer: $external_completer
+# }
+# }
+# # ...
+#}
diff --git a/dot_config/nushell/autoload/lfcd.nu b/dot_config/nushell/autoload/lfcd.nu
new file mode 100644
index 0000000..d850902
--- /dev/null
+++ b/dot_config/nushell/autoload/lfcd.nu
@@ -0,0 +1,4 @@
+alias lf-default = lf
+def --env --wrapped lf [...argv] {
+ cd (lf-default -print-last-dir ...$argv)
+}