From 75254c3434288515111195173e6922bfba5feda8 Mon Sep 17 00:00:00 2001 From: Jason Morganson <128727+jasonmorganson@users.noreply.github.com> Date: Tue, 7 Jan 2025 15:47:44 -0500 Subject: [PATCH] Use go template to parse and translate aliases into nu --- home/dot_config/nushell/scripts/aliases.nu.tmpl | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/home/dot_config/nushell/scripts/aliases.nu.tmpl b/home/dot_config/nushell/scripts/aliases.nu.tmpl index 5e2cfce..88fe89d 100644 --- a/home/dot_config/nushell/scripts/aliases.nu.tmpl +++ b/home/dot_config/nushell/scripts/aliases.nu.tmpl @@ -1,3 +1,10 @@ {{- $mise := joinPath .chezmoi.homeDir ".local/bin/mise" -}} - -{{ output $mise "exec" "ubi:nushell/nushell[exe=nu]" "--" "nu" "-c" (print $mise " use rust out+err> /dev/null;" $mise " exec cargo:https://github.com/nomyfan/alias-rs@branch:main -- als init zsh | lines | skip 2 | parse 'alias {name}=\"{value}\"' | each {|alias| print $\"export alias ($alias.name) = ($alias.value)\" } | ignore; exit") }} +{{- $aliases := output $mise "exec" "rust" "--" $mise "exec" "cargo:https://github.com/nomyfan/alias-rs@branch:main" "--" "als" "init" "bash" -}} +{{- range $index, $line := splitList "\n" $aliases -}} + {{- if hasPrefix "alias" $line -}} + {{- $parts := splitn "=" 2 $line -}} + {{- $name := $parts._0 -}} + {{- $value := $parts._1 -}} + {{- nindent 0 (printf "export %s = %s" $name ($value | replace "\"" "")) -}} + {{- end -}} +{{- end -}} \ No newline at end of file