Skip to content

Commit

Permalink
Use go template to parse and translate aliases into nu
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonmorganson committed Jan 7, 2025
1 parent d8dcae6 commit 460c7e5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions home/dot_config/nushell/scripts/aliases.nu.tmpl
Original file line number Diff line number Diff line change
@@ -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 -}}

0 comments on commit 460c7e5

Please sign in to comment.