From 2117c1bb35f0da218077f78a4ea72f247e40c8dd Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Sat, 10 Dec 2022 09:14:30 -0600 Subject: [PATCH] change `for` to `each` in oh-my.nu (#323) --- prompt/oh-my.nu | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/prompt/oh-my.nu b/prompt/oh-my.nu index 50c2399..12b08dd 100644 --- a/prompt/oh-my.nu +++ b/prompt/oh-my.nu @@ -35,6 +35,7 @@ def path_abbrev_if_needed [apath term_width] { let P = (ansi { fg: "#E4E4E4" bg: "#3465A4"}) # path let PB = (ansi { fg: "#E4E4E4" bg: "#3465A4" attr: b}) # path bold let R = (ansi reset) + let is_home_in_path = ($env.PWD | str starts-with $nu.home-path) if (($apath | str length) > ($term_width / 2)) { # split out by path separator into tokens @@ -42,9 +43,8 @@ def path_abbrev_if_needed [apath term_width] { let splits = ($apath | split row '/') let splits_len = ($splits | length) - let subtractor = (if ($splits_len <= 2) { 1 } else { 2 }) # get all the tokens except the last - let tokens = (for x in 1..($splits_len - $subtractor) { + let tokens = (1..<$splits_len | each {|x| $"($T)((($splits) | get $x | split chars) | get 0)($R)" }) @@ -87,7 +87,7 @@ def path_abbrev_if_needed [apath term_width] { } else { let top_part = ($splits | first ($splits_len - 1)) let end_part = ($splits | last) - let tokens = (for x in $top_part { + let tokens = ($top_part | each {|x| $"/($T)(($x | split chars).0)($R)" }) let tokens = ($tokens | append $"/($PB)($end_part)($R)")