mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-02 07:07:46 +00:00
remove the boolean vars (#182)
This commit is contained in:
parent
d7bb156d80
commit
ec2eaab836
8 changed files with 39 additions and 39 deletions
|
@ -374,9 +374,9 @@ def "nu-complete winget source type" [] {
|
|||
|
||||
def "nu-complete winget flagify" [name: string, value: any, --short(-s): bool] {
|
||||
let flag_start = if $short { '-' } else { '--' }
|
||||
if $value == $nothing || $value == $false {
|
||||
if $value == $nothing || $value == false {
|
||||
""
|
||||
} else if $value == $true {
|
||||
} else if $value == true {
|
||||
$"($flag_start)($name)"
|
||||
} else {
|
||||
$"($flag_start)($name) ($value)"
|
||||
|
@ -408,8 +408,8 @@ def "nu-complete winget install name" [] {
|
|||
{
|
||||
completions: $completions
|
||||
options: {
|
||||
case_sensitive: $false
|
||||
positional: $false
|
||||
case_sensitive: false
|
||||
positional: false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,10 +42,10 @@ def get_flag [
|
|||
let is_int_empty = ($test_int == $nothing)
|
||||
let is_string_empty = ($test_string == $nothing)
|
||||
|
||||
let no_int_no_string = ($is_int_empty == $true && $is_string_empty == $true)
|
||||
let no_int_with_string = ($is_int_empty == $true && $is_string_empty == $false)
|
||||
let with_int_no_string = ($is_int_empty == $false && $is_string_empty == $true)
|
||||
let with_int_with_string = ($is_int_empty == $false && $is_string_empty == $false)
|
||||
let no_int_no_string = ($is_int_empty == true && $is_string_empty == true)
|
||||
let no_int_with_string = ($is_int_empty == true && $is_string_empty == false)
|
||||
let with_int_no_string = ($is_int_empty == false && $is_string_empty == true)
|
||||
let with_int_with_string = ($is_int_empty == false && $is_string_empty == false)
|
||||
|
||||
echo 'no int and no string ' $no_int_no_string | str collect
|
||||
echo 'no int with string ' $no_int_with_string | str collect
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
# Abbreviate home path
|
||||
def home_abbrev [os] {
|
||||
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
||||
if ($is_home_in_path == $true) {
|
||||
if ($is_home_in_path == true) {
|
||||
if ($os == "Windows") {
|
||||
let home = ($nu.home-path | str find-replace -a '\\' '/')
|
||||
let pwd = ($env.PWD | str find-replace -a '\\' '/')
|
||||
|
@ -102,7 +102,7 @@ def path_abbrev_if_needed [apath term_width] {
|
|||
|
||||
def get_os_icon [os use_nerd_fonts] {
|
||||
# f17c = tux, f179 = apple, f17a = windows
|
||||
if ($use_nerd_fonts == $true) {
|
||||
if $use_nerd_fonts {
|
||||
if ($os =~ Darwin) {
|
||||
(char -u f179)
|
||||
} else if ($os =~ Linux) {
|
||||
|
@ -157,7 +157,7 @@ def get_left_prompt [os use_nerd_fonts] {
|
|||
(get_os_icon $os $use_nerd_fonts) # os icon
|
||||
(char space) # space
|
||||
(ansi { fg: "#CED7CF" bg: "#3465A4"}) # color transition
|
||||
(if ($use_nerd_fonts == $true) {
|
||||
(if $use_nerd_fonts {
|
||||
$right_transition_nf #
|
||||
} else {
|
||||
$right_transition
|
||||
|
@ -168,7 +168,7 @@ def get_left_prompt [os use_nerd_fonts] {
|
|||
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
||||
let path_segment = (if $is_home_in_path {
|
||||
[
|
||||
(if ($use_nerd_fonts == $true) {
|
||||
(if $use_nerd_fonts {
|
||||
$home_nf # home icon
|
||||
} else {
|
||||
$home
|
||||
|
@ -180,7 +180,7 @@ def get_left_prompt [os use_nerd_fonts] {
|
|||
] | str collect
|
||||
} else {
|
||||
[
|
||||
(if ($use_nerd_fonts == $true) {
|
||||
(if $use_nerd_fonts {
|
||||
$folder_nf # folder icon
|
||||
} else {
|
||||
$folder
|
||||
|
@ -195,7 +195,7 @@ def get_left_prompt [os use_nerd_fonts] {
|
|||
let indicator_segment = (
|
||||
[
|
||||
(ansi { fg: "#3465A4" bg: $TERM_BG}) # color
|
||||
(if ($use_nerd_fonts == $true) {
|
||||
(if $use_nerd_fonts {
|
||||
$right_transition_nf #
|
||||
} else {
|
||||
# $right_transition
|
||||
|
@ -231,7 +231,7 @@ def get_right_prompt [os use_nerd_fonts] {
|
|||
|
||||
let datetime_segment = ([
|
||||
(ansi { fg: $TIME_BG bg: $TERM_FG})
|
||||
(if ($use_nerd_fonts == $true) {
|
||||
(if $use_nerd_fonts {
|
||||
$left_transition_nf #
|
||||
} else {
|
||||
$left_transition
|
||||
|
@ -245,7 +245,7 @@ def get_right_prompt [os use_nerd_fonts] {
|
|||
|
||||
let time_segment = ([
|
||||
(ansi { fg: $TIME_BG bg: $TERM_FG})
|
||||
(if ($use_nerd_fonts == $true) {
|
||||
(if $use_nerd_fonts {
|
||||
$left_transition_nf #
|
||||
} else {
|
||||
$left_transition
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
# Abbreviate home path
|
||||
def home_abbrev [os_name] {
|
||||
let is_home_in_path = ($env.PWD | str starts-with $nu.home-path)
|
||||
if ($is_home_in_path == $true) {
|
||||
if $is_home_in_path {
|
||||
if ($os_name == "Windows") {
|
||||
let home = ($nu.home-path | str find-replace -a '\\' '/')
|
||||
let pwd = ($env.PWD | str find-replace -a '\\' '/')
|
||||
|
@ -218,9 +218,9 @@ def get_repo_status [gs os] {
|
|||
($wt_change_cnt <= 0) &&
|
||||
($conflicted_cnt <= 0) &&
|
||||
($untracked_cnt <= 0) {
|
||||
$true
|
||||
true
|
||||
} else {
|
||||
$false
|
||||
false
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -282,7 +282,7 @@ def get_repo_status [gs os] {
|
|||
)(
|
||||
if ($untracked_cnt > 0) { $'($U_COLOR)($UNTRACKED_CHANGE_ICON)($untracked_cnt)($R)' }
|
||||
)(
|
||||
if ($has_no_changes == $true) { $'($N_COLOR)($NO_CHANGE_ICON)($R)' } else { $'($H_COLOR)($HAS_CHANGE_ICON)($R)' }
|
||||
if $has_no_changes { $'($N_COLOR)($NO_CHANGE_ICON)($R)' } else { $'($H_COLOR)($HAS_CHANGE_ICON)($R)' }
|
||||
)"
|
||||
)
|
||||
|
||||
|
@ -362,8 +362,8 @@ def git_left_prompt [gs os] {
|
|||
] | str collect
|
||||
})
|
||||
|
||||
let git_right = $false
|
||||
let indicator_segment = (if ($branch_name == "" || $git_right == $true) {
|
||||
let git_right = false
|
||||
let indicator_segment = (if ($branch_name == "" || $git_right) {
|
||||
[
|
||||
(ansi { fg: "#3465A4" bg: $TERM_BG}) # color
|
||||
(char -u e0b0) #
|
||||
|
@ -381,7 +381,7 @@ def git_left_prompt [gs os] {
|
|||
[
|
||||
$os_segment
|
||||
$path_segment
|
||||
(if ($git_right == $false) {
|
||||
(if ($git_right == false) {
|
||||
$git_segment
|
||||
})
|
||||
$indicator_segment
|
||||
|
|
|
@ -27,16 +27,16 @@ def __zoxide_prompt [] {
|
|||
|
||||
# Hook to add new entries to the database.
|
||||
def __zoxide_hook [] {
|
||||
# shells | where active == $true | get path | each {
|
||||
# shells | where active == true | get path | each {
|
||||
# zoxide add -- $it
|
||||
# }
|
||||
zoxide add -- (shells | where active == $true | get path | get 0)
|
||||
zoxide add -- (shells | where active == true | get path | get 0)
|
||||
}
|
||||
|
||||
# Initialize hook.
|
||||
|
||||
export env ZOXIDE_INITIALIZED { (if ("ZOXIDE_INITIALIZED" not-in (env).name) {
|
||||
$false
|
||||
false
|
||||
} else {
|
||||
$env.ZOXIDE_INITIALIZED
|
||||
})
|
||||
|
@ -73,7 +73,7 @@ export env PROMPT_COMMAND {
|
|||
# Jump to a directory using only keywords.
|
||||
# export def-env __zoxide_z [...rest:string] {
|
||||
export def-env z [...rest:string] {
|
||||
# if (shells | where active == $true) {
|
||||
# if (shells | where active == true) {
|
||||
# if ($rest | length) > 1 {
|
||||
# $'zoxide: can only jump in active shells(char nl)'
|
||||
# } else {
|
||||
|
@ -92,7 +92,7 @@ export def-env z [...rest:string] {
|
|||
# Jump to a directory using interactive search.
|
||||
# export def-env __zoxide_zi [...rest:string] {
|
||||
export def-env zi [...rest:string] {
|
||||
# if (shells | where active == $false) {
|
||||
# if (shells | where active == false) {
|
||||
# $'zoxide: can only jump in active shells(char nl)'
|
||||
# } else {
|
||||
# cd $'(zoxide query -i -- $rest.0)'
|
||||
|
@ -120,7 +120,7 @@ export def-env zi [...rest:string] {
|
|||
|
||||
# If everything went fine, set a flag that zoxide is initialized to avoid
|
||||
# recursively calling _OLD_PROMPT_COMMAND
|
||||
export env ZOXIDE_INITIALIZED { $true }
|
||||
export env ZOXIDE_INITIALIZED { true }
|
||||
|
||||
|
||||
# HOW TO
|
||||
|
|
|
@ -168,10 +168,10 @@ export def get_weather [
|
|||
let is_loc_empty = ($locIdx == $nothing)
|
||||
let is_units_empty = ($units == $nothing)
|
||||
|
||||
let no_loc_no_unit = ($is_loc_empty == $true && $is_units_empty == $true)
|
||||
let no_loc_with_unit = ($is_loc_empty == $true && $is_units_empty == $false)
|
||||
let with_loc_no_unit = ($is_loc_empty == $false && $is_units_empty == $true)
|
||||
let with_loc_with_unit = ($is_loc_empty == $false && $is_units_empty == $false)
|
||||
let no_loc_no_unit = ($is_loc_empty == true && $is_units_empty == true)
|
||||
let no_loc_with_unit = ($is_loc_empty == true && $is_units_empty == false)
|
||||
let with_loc_no_unit = ($is_loc_empty == false && $is_units_empty == true)
|
||||
let with_loc_with_unit = ($is_loc_empty == false && $is_units_empty == false)
|
||||
|
||||
# This is a cautionary tale, the commented out code below is returning
|
||||
# and autoview is viewing the data, so no structured data is being returned.
|
||||
|
|
|
@ -36,7 +36,7 @@ def signatures [] {
|
|||
long: "help"
|
||||
short: "h"
|
||||
arg: None
|
||||
required: $false
|
||||
required: false
|
||||
desc: "display this help message"
|
||||
var_id: None
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ def signatures [] {
|
|||
long: "flag"
|
||||
short: "f"
|
||||
arg: None
|
||||
required: $false
|
||||
required: false
|
||||
desc: "a flag for the signature"
|
||||
var_id: None
|
||||
}
|
||||
|
@ -52,13 +52,13 @@ def signatures [] {
|
|||
long: "named"
|
||||
short: "n"
|
||||
arg: "String"
|
||||
required: $false
|
||||
required: false
|
||||
desc: "named string"
|
||||
var_id: None
|
||||
}
|
||||
]
|
||||
is_filter: $false
|
||||
creates_scope: $false
|
||||
is_filter: false
|
||||
creates_scope: false
|
||||
category: "Experimental"
|
||||
}
|
||||
])
|
||||
|
|
|
@ -26,7 +26,7 @@ def timed_weather_run [
|
|||
# generate temp file name
|
||||
let weather_runtime_file = (($env.TMP) | path join weather_runtime_file.json)
|
||||
# does the temp file already exist, meaning we've written it previously
|
||||
if ($weather_runtime_file | path exists) == $true {
|
||||
if ($weather_runtime_file | path exists) {
|
||||
# $"Weather path exists [($weather_runtime_file)](char nl)"
|
||||
# open the file and get the last weather data and run time out of it
|
||||
let last_runtime_data = (open $weather_runtime_file)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue