mirror of
https://github.com/Cian-H/dotfiles.git
synced 2025-12-23 03:41:57 +00:00
Fixed nushell function definitions
As of 0.102.0 it seems that setting type in and out with arrows in nushell implies a piped only function? Whatever the justification, this broke my functions in nushell and this change seems to fix them.
This commit is contained in:
@@ -1,24 +1,24 @@
|
|||||||
def get_env [s: string]: string -> any {
|
def get_env [s: string] {
|
||||||
try { $env | get --ignore-errors $s } catch { "" }
|
try { $env | get --ignore-errors $s } catch { "" }
|
||||||
}
|
}
|
||||||
|
|
||||||
export def was_successful []: nothing -> bool {
|
export def was_successful [] {
|
||||||
(get_env "LAST_EXIT_CODE") == 0
|
(get_env "LAST_EXIT_CODE") == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
export def create_left_prompt []: nothing -> string {
|
export def create_left_prompt [] {
|
||||||
^starship prompt --cmd-duration (get_env "CMD_DURATION_MS") $'--status=($env.LAST_EXIT_CODE)' --terminal-width (term size).columns
|
^starship prompt --cmd-duration (get_env "CMD_DURATION_MS") $'--status=($env.LAST_EXIT_CODE)' --terminal-width (term size).columns
|
||||||
}
|
}
|
||||||
|
|
||||||
export def create_right_prompt []: nothing -> string {
|
export def create_right_prompt [] {
|
||||||
^starship prompt --right --cmd-duration (get_env "CMD_DURATION_MS") $'--status=($env.LAST_EXIT_CODE)' --terminal-width (term size).columns
|
^starship prompt --right --cmd-duration (get_env "CMD_DURATION_MS") $'--status=($env.LAST_EXIT_CODE)' --terminal-width (term size).columns
|
||||||
}
|
}
|
||||||
|
|
||||||
export def create_continuation_prompt []: nothing -> string {
|
export def create_continuation_prompt [] {
|
||||||
^starship prompt --continuation --cmd-duration (get_env "CMD_DURATION_MS") $'--status=($env.LAST_EXIT_CODE)' --terminal-width (term size).columns
|
^starship prompt --continuation --cmd-duration (get_env "CMD_DURATION_MS") $'--status=($env.LAST_EXIT_CODE)' --terminal-width (term size).columns
|
||||||
}
|
}
|
||||||
|
|
||||||
def parse_ms_to_human_readable [ms: string]: string -> string {
|
def parse_ms_to_human_readable [ms: string] {
|
||||||
if $ms == "" {
|
if $ms == "" {
|
||||||
$ms
|
$ms
|
||||||
} else {
|
} else {
|
||||||
@@ -37,13 +37,13 @@ def parse_ms_to_human_readable [ms: string]: string -> string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export def create_transient_prompt_left []: nothing -> string {
|
export def create_transient_prompt_left [] {
|
||||||
if (was_successful) {
|
if (was_successful) {
|
||||||
$"(ansi green_bold)(ansi reset)"
|
$"(ansi green_bold)(ansi reset)"
|
||||||
} else {
|
} else {
|
||||||
$"(ansi red_bold)(ansi reset)"
|
$"(ansi red_bold)(ansi reset)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export def create_transient_prompt_indicator []: nothing -> string {
|
export def create_transient_prompt_indicator [] {
|
||||||
$"(ansi blue_bold) (parse_ms_to_human_readable (get_env "CMD_DURATION_MS")) (if (was_successful) { ansi green_bold } else { ansi red_bold })(ansi reset) "
|
$"(ansi blue_bold) (parse_ms_to_human_readable (get_env "CMD_DURATION_MS")) (if (was_successful) { ansi green_bold } else { ansi red_bold })(ansi reset) "
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
export def 'exists' [ app ]: string -> bool {
|
export def 'exists' [ app ] {
|
||||||
not (which $app | is-empty)
|
not (which $app | is-empty)
|
||||||
}
|
}
|
||||||
|
|
||||||
export def 'sysfetch' []: nothing -> nothing {
|
export def 'sysfetch' [] {
|
||||||
if (exists fastfetch) {
|
if (exists fastfetch) {
|
||||||
if (("kitty" in $env.TERM) or ("ghostty" in $env.TERM)) and ($"($env.HOME)/.config/fastfetch/kitty.jsonc" | path exists) {
|
if (("kitty" in $env.TERM) or ("ghostty" in $env.TERM)) and ($"($env.HOME)/.config/fastfetch/kitty.jsonc" | path exists) {
|
||||||
fastfetch --load-config $"($env.HOME)/.config/fastfetch/kitty.jsonc"
|
fastfetch --load-config $"($env.HOME)/.config/fastfetch/kitty.jsonc"
|
||||||
@@ -23,7 +23,7 @@ export def 'sysfetch' []: nothing -> nothing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export def 'register-plugins' []: nothing -> nothing {
|
export def 'register-plugins' [] {
|
||||||
for plugin_dir in $env.NU_PLUGIN_DIRS {
|
for plugin_dir in $env.NU_PLUGIN_DIRS {
|
||||||
for plugin_path in (ls $"($env.NU_PLUGIN_DIRS.0)/nu_plugin_*").name {
|
for plugin_path in (ls $"($env.NU_PLUGIN_DIRS.0)/nu_plugin_*").name {
|
||||||
nu -c $"register ($plugin_path)"
|
nu -c $"register ($plugin_path)"
|
||||||
@@ -31,7 +31,7 @@ export def 'register-plugins' []: nothing -> nothing {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export def 'build-plugins' []: nothing -> nothing {
|
export def 'build-plugins' [] {
|
||||||
let curdir = pwd
|
let curdir = pwd
|
||||||
let plugin_dir = $env.NU_PLUGIN_DIRS.0
|
let plugin_dir = $env.NU_PLUGIN_DIRS.0
|
||||||
cd $plugin_dir
|
cd $plugin_dir
|
||||||
@@ -40,7 +40,7 @@ export def 'build-plugins' []: nothing -> nothing {
|
|||||||
register-plugins
|
register-plugins
|
||||||
}
|
}
|
||||||
|
|
||||||
export def 'install-default-plugins' []: nothing -> nothing {
|
export def 'install-default-plugins' [] {
|
||||||
[ nu_plugin_inc
|
[ nu_plugin_inc
|
||||||
nu_plugin_polars
|
nu_plugin_polars
|
||||||
# nu_plugin_gstat
|
# nu_plugin_gstat
|
||||||
|
|||||||
Reference in New Issue
Block a user