-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove fast mode.
- Loading branch information
Showing
7 changed files
with
814 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export def logtime [msg act] { | ||
let start = date now | ||
let result = do $act | ||
# HACK: serialization | ||
let period = (date now) - $start | format duration ns | str replace ' ' '' | ||
|
||
echo $'($start | format date '%Y-%m-%d_%H:%M:%S%z')(char tab)($period)(char tab)($msg)(char newline)' | ||
| save -a ~/.cache/nushell/power_time.log | ||
|
||
$result | ||
} | ||
|
||
export def timelog [] { | ||
open ~/.cache/nushell/power_time.log | ||
| from tsv -n | ||
| rename start duration message | ||
| each {|x| | ||
$x | ||
| update start ($x.start | into datetime -f '%Y-%m-%d_%H:%M:%S%z') | ||
| update duration ($x.duration | into duration) | ||
} | ||
} | ||
|
||
export def analyze [] { | ||
timelog | ||
| group-by message | ||
| transpose component metrics | ||
| each {|x| $x | upsert metrics ($x.metrics | get duration | math avg)} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
def 'path parents' [] { | ||
let p = $in | path expand | path split | ||
mut r = [] | ||
for i in ($p | length | $in - 1)..0 { | ||
$r ++= { a: ($p | range 0..$i), b: ($p | range ($i + 1)..) } | ||
} | ||
$r | ||
} | ||
|
||
def 'find vcs' [] { | ||
for i in ($in | path parents) { | ||
if ($i.a | append '.git' | path join | path exists) { | ||
return $i | ||
} | ||
} | ||
} | ||
|
||
export def "pwd_abbr" [] { | ||
{|bg| | ||
let vcso = $env.PWD | find vcs | ||
let no_vcs = $vcso | is-empty | ||
let vcs = if $no_vcs { | ||
[$env.PWD] | ||
} else { | ||
[($vcso.a | path join), ($vcso.b | path join)] | ||
} | ||
let relative = do -i { $vcs.0 | path relative-to $env.HOME } | ||
let in_home = ($relative | describe -d).type == 'string' | ||
|
||
let cwd = if $in_home { | ||
if ($relative | is-empty) { '~' } else { $'~(char separator)($relative)' } | ||
} else { | ||
$vcs.0 | ||
} | ||
|
||
mut dir_comp = ($cwd | path split) | ||
|
||
if ($dir_comp | length) + ($vcso.b? | default 0 | length) > 5 { | ||
let first = $dir_comp | first | ||
let last = $dir_comp | last | ||
let body = $dir_comp | ||
|range 1..-2 | ||
|each {|x| $x | str substring ..<2 } | ||
$dir_comp = ([$first $body $last] | flatten) | ||
} | ||
let dir_comp = $dir_comp | path join | ||
|
||
let theme = $env.NU_POWER_THEME.pwd | ||
|
||
let tm = if $in_home { $theme.default } else { $theme.out_home } | ||
let fg = if $no_vcs { | ||
$"($tm)($dir_comp)" | ||
} else { | ||
if ($vcs.1 | is-empty) { | ||
$"($tm)($dir_comp)" | ||
} else { | ||
[$"($tm)($dir_comp)($theme.vcs)" $"($vcs.1)"] | ||
| path join | ||
} | ||
} | ||
[$bg $fg] | ||
} | ||
} |
Oops, something went wrong.