mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 06:37:46 +00:00
a pretty functional prompt
This commit is contained in:
parent
348d6a5342
commit
9df889ea2e
1 changed files with 26 additions and 6 deletions
|
@ -1,11 +1,31 @@
|
|||
# This is a work in progress. Not working yet but you can see where I'm going.
|
||||
let decorator = '#'
|
||||
def construct_prompt [] {
|
||||
let decorator = $(char prompt)
|
||||
let machine_name = $(sys | get host.hostname)
|
||||
let current_dir = $(pwd)
|
||||
let git_info = $(do -i { git rev-parse --abbrev-ref HEAD } | str trim | str collect )
|
||||
let title_bar = $(set_title)
|
||||
let git_status = $(git -c core.quotepath=false -c color.status=false status -uall --short --branch)
|
||||
let term_width = $(term size -w)
|
||||
let current_time = $(date now | date format '%I:%M:%S%.3f %p')
|
||||
|
||||
let left_colored = $(build-string $(ansi gb) $current_dir $(ansi cb) '(' $git_info ')' $(ansi reset))
|
||||
let left_len = $(echo $left_colored | ansi strip | str length)
|
||||
let right_colored = $(build-string $(ansi blue) $(echo $nu.env.CMD_DURATION) '|' $(ansi yb) $current_time $(ansi reset))
|
||||
let right_colored_len = $(echo $right_colored | str length)
|
||||
let right_len = $(echo $right_colored | ansi strip | str length)
|
||||
let calculated_right_len = $(= $term_width - $left_len + ($right_colored_len - $right_len))
|
||||
let the_prompt = $(build-string $left_colored $(echo $right_colored | str lpad -c ' ' -l $calculated_right_len) $(char newline) $decorator ' ')
|
||||
|
||||
# let left = $(build-string $current_dir '(' $git_info ')')
|
||||
# let right = $(build-string $current_time)
|
||||
# let the_prompt = $(build-string $left $(echo $right | str lpad -c ' ' -l $(= $term_width - $(echo $left | str length))) $(char newline) $decorator ' ')
|
||||
|
||||
echo $the_prompt | str collect
|
||||
|
||||
## put this in your config.toml
|
||||
# prompt = "construct_prompt"
|
||||
}
|
||||
|
||||
# Get Git Info custom commands
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue