This commit is contained in:
Thomas Forgione 2023-11-08 16:55:17 +01:00
parent b71c844ac4
commit 166645f0c0
2 changed files with 19 additions and 19 deletions

View File

@ -19,63 +19,63 @@ $env.config.filesize = {
format: "auto" format: "auto"
} }
$env.config.table.mode = none $env.config.table.mode = light
# ls aliases # ls aliases
alias _ls = ls alias _ls = ls
def _ls_format_mode [mode: string] { def _ls_format_mode [mode: string] {
let chars = echo $mode | split chars let chars = $mode | split chars
let r1 = (if (echo $chars | get 0) == "r" { let r1 = (if ($chars | get 0) == "r" {
[(ansi yellow_bold), "r", (ansi reset)] [(ansi yellow_bold), "r", (ansi reset)]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let w1 = (if (echo $chars | get 1) == "w" { let w1 = (if ($chars | get 1) == "w" {
[(ansi red_bold), "w", (ansi reset)] [(ansi red_bold), "w", (ansi reset)]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let x1 = (if (echo $chars | get 2) == "x" { let x1 = (if ($chars | get 2) == "x" {
[(ansi green_bold), "x", (ansi reset)] [(ansi green_bold), "x", (ansi reset)]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let r2 = (if (echo $chars | get 3) == "r" { let r2 = (if ($chars | get 3) == "r" {
[(ansi yellow), "r", (ansi reset)] [(ansi yellow), "r", (ansi reset)]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let w2 = (if (echo $chars | get 4) == "w" { let w2 = (if ($chars | get 4) == "w" {
[(ansi red), "w"] [(ansi red), "w"]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let x2 = (if (echo $chars | get 5) == "x" { let x2 = (if ($chars | get 5) == "x" {
[(ansi green), "x"] [(ansi green), "x"]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let r3 = (if (echo $chars | get 6) == "r" { let r3 = (if ($chars | get 6) == "r" {
[(ansi yellow), "r", (ansi reset)] [(ansi yellow), "r", (ansi reset)]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let w3 = (if (echo $chars | get 7) == "w" { let w3 = (if ($chars | get 7) == "w" {
[(ansi red), "w"] [(ansi red), "w"]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
} | str join) } | str join)
let x3 = (if (echo $chars | get 8) == "x" { let x3 = (if ($chars | get 8) == "x" {
[(ansi green), "x"] [(ansi green), "x"]
} else { } else {
[(ansi grey), "-"] [(ansi grey), "-"]
@ -109,13 +109,13 @@ def ls [dir?: string] {
def la [dir?: string] { def la [dir?: string] {
_ls -al (if $dir == null { "" } else { $dir }) _ls -al (if $dir == null { "" } else { $dir })
| sort-by type name -i | sort-by type name -i
| each {|x| return (echo $x | update mode (_ls_format_mode $x.mode))} | each { $in | update mode (_ls_format_mode $in.mode) }
| select mode name target user size modified | select mode name target user size modified
} }
def ll [dir?: string] { def ll [dir?: string] {
_ls -l (if $dir == null { "" } else { $dir }) _ls -l (if $dir == null { "" } else { $dir })
| each {|x| return (echo $x | update mode (_ls_format_mode $x.mode))} | each { $in | update mode (_ls_format_mode $in.mode) }
| sort-by type name -i | sort-by type name -i
| select mode name target user size modified | select mode name target user size modified
} }
@ -153,7 +153,7 @@ def _ssh_hosts [] {
open .ssh/config open .ssh/config
| lines | lines
| find -ir "host " | find -ir "host "
| each {|x| echo $x | split row " " | get 1 } | each { $in | split row " " | get 1 }
} }
export extern "ssh" [ export extern "ssh" [
@ -186,8 +186,8 @@ def _gclone_dirs [] {
let slashes = ($env.GCLONE_PATH | split row "/" | length) + 2 let slashes = ($env.GCLONE_PATH | split row "/" | length) + 2
open ([$env.GCLONE_PATH, .cdgcache] | path join) open ([$env.GCLONE_PATH, .cdgcache] | path join)
| lines | lines
| where {|x| (echo $x | split row "/" | length) >= $slashes } | where { ($in | split row "/" | length) >= $slashes }
| each {|x| $x | split row "/" | last } | each { $in | split row "/" | last }
| sort | sort
| uniq | uniq
} }
@ -231,7 +231,7 @@ def-env kube [name?: string@_kube_kubes] {
error make {msg: ([$kube_config, " does not exist"] | str join)} error make {msg: ([$kube_config, " does not exist"] | str join)}
} }
echo $kube_config | save -f ([$kubes_path, current-cube] | path join) $kube_config | save -f ([$kubes_path, current-cube] | path join)
$env.KUBECONFIG = $kube_config $env.KUBECONFIG = $kube_config
} }

View File

@ -56,7 +56,7 @@ def create_left_prompt [] {
let git_color = [(ansi reset), (ansi yellow)] | str join let git_color = [(ansi reset), (ansi yellow)] | str join
let git_branch = do { git rev-parse --abbrev-ref HEAD } let git_branch = do { git rev-parse --abbrev-ref HEAD }
| complete | complete
| update stdout (echo $in.stdout | str trim -c "\n") | update stdout ($in.stdout | str trim -c "\n")
let git_status = do { git status -s } | complete | get stdout | str trim -c "\n" let git_status = do { git status -s } | complete | get stdout | str trim -c "\n"
@ -74,7 +74,7 @@ def create_left_prompt [] {
# Current kube # Current kube
let kube_color = ansi cyan_bold let kube_color = ansi cyan_bold
let kube = if (echo ~/.kubes/current-cube | path exists) { let kube = if ("~/.kubes/current-cube" | path exists) {
let kube_name = open ~/.kubes/current-cube | path dirname | path basename let kube_name = open ~/.kubes/current-cube | path dirname | path basename
[$kube_color, " ", $kube_name, ""] | str join [$kube_color, " ", $kube_name, ""] | str join