diff --git a/nushell/modules/pj_helix.nu b/nushell/modules/pj_helix.nu new file mode 100644 index 0000000..30a9f25 --- /dev/null +++ b/nushell/modules/pj_helix.nu @@ -0,0 +1,33 @@ +export-env { + $env.PJ_HELIX_CONFIG_PATH = $env.NU_POLYJUICE_PATH | path join ".." "helix" "config.toml" +} + +export def hx [...rest: string] { + if (which ^helix | is-not-empty) { + ^helix -c $env.PJ_HELIX_CONFIG_PATH ...$rest + } else if (which ^hx | is-not-empty) { + ^hx -c $env.PJ_HELIX_CONFIG_PATH ...$rest + } else { + print "Helix editor not found." + if ($env.OS == "Windows_NT") { + print "You can install Helix via `winget install Helix.Helix`" + } else { + print "You can install Helix from package managers." + } + } +} + +export def helix [...rest: string] { + if (which ^helix | is-not-empty) { + ^helix -c $env.PJ_HELIX_CONFIG_PATH ...$rest + } else if (which ^hx | is-not-empty) { + ^hx -c $env.PJ_HELIX_CONFIG_PATH ...$rest + } else { + print "Helix editor not found." + if ($env.OS == "Windows_NT") { + print "You can install Helix via `winget install Helix.Helix`" + } else { + print "You can install Helix from package managers." + } + } +} diff --git a/nushell/modules/pj_prompt.nu b/nushell/modules/pj_prompt.nu index af2497e..e96cf0f 100644 --- a/nushell/modules/pj_prompt.nu +++ b/nushell/modules/pj_prompt.nu @@ -1,6 +1,6 @@ export def --env "pj starship config" [name: string] { if (which ^starship | is-empty) { - echo "starship is not installed." | warn + echo "starship is not installed." return } $env.starship_config = ($env.NU_POLYJUICE_PATH | path join ".." "starship" $"starship_($name).toml") @@ -8,7 +8,7 @@ export def --env "pj starship config" [name: string] { export def --env "pj starship list" [] { if (which ^starship | is-empty) { - echo "starship is not installed." | warn + echo "starship is not installed." return } ls ($env.NU_POLYJUICE_PATH | path join ".." "starship") -s | get name | parse -r '^(starship_(?.*).toml)$' | get name diff --git a/nushell/nu_polyjuice.nu b/nushell/nu_polyjuice.nu index 277d50b..fcb35c2 100644 --- a/nushell/nu_polyjuice.nu +++ b/nushell/nu_polyjuice.nu @@ -6,6 +6,7 @@ $env.NU_POLYJUICE_PATH = $env.FILE_PWD # modules use modules/pj_aliases.nu * +use modules/pj_helix.nu * use modules/pj_fzf.nu * use modules/pj_zoxide.nu * use modules/pj_prompt.nu *