set up nushell
This commit is contained in:
parent
a44e3b3305
commit
607eb41d72
|
@ -143,7 +143,7 @@ let light_theme = {
|
||||||
|
|
||||||
# The default config record. This is where much of your global configuration is setup.
|
# The default config record. This is where much of your global configuration is setup.
|
||||||
$env.config = {
|
$env.config = {
|
||||||
show_banner: true # true or false to enable or disable the welcome banner at startup
|
show_banner: false # true or false to enable or disable the welcome banner at startup
|
||||||
|
|
||||||
ls: {
|
ls: {
|
||||||
use_ls_colors: true # use the LS_COLORS environment variable to colorize output
|
use_ls_colors: true # use the LS_COLORS environment variable to colorize output
|
||||||
|
@ -155,7 +155,7 @@ $env.config = {
|
||||||
}
|
}
|
||||||
|
|
||||||
table: {
|
table: {
|
||||||
mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
|
mode: dots # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other
|
||||||
index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column
|
index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column
|
||||||
show_empty: true # show 'empty list' and 'empty record' placeholders for command output
|
show_empty: true # show 'empty list' and 'empty record' placeholders for command output
|
||||||
padding: { left: 1, right: 1 } # a left right padding of each column in a table
|
padding: { left: 1, right: 1 } # a left right padding of each column in a table
|
||||||
|
@ -234,7 +234,7 @@ $env.config = {
|
||||||
use_ansi_coloring: true
|
use_ansi_coloring: true
|
||||||
bracketed_paste: true # enable bracketed paste, currently useless on windows
|
bracketed_paste: true # enable bracketed paste, currently useless on windows
|
||||||
edit_mode: emacs # emacs, vi
|
edit_mode: emacs # emacs, vi
|
||||||
shell_integration: false # enables terminal shell integration. Off by default, as some terminals have issues with this.
|
shell_integration: true # enables terminal shell integration. Off by default, as some terminals have issues with this.
|
||||||
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
|
render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt.
|
||||||
use_kitty_protocol: false # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this.
|
use_kitty_protocol: false # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this.
|
||||||
highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which.
|
highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which.
|
||||||
|
|
|
@ -2,6 +2,50 @@
|
||||||
#
|
#
|
||||||
# version = "0.91.1"
|
# version = "0.91.1"
|
||||||
|
|
||||||
|
def git_prompt [] {
|
||||||
|
if (do --ignore-errors { git rev-parse --abbrev-ref HEAD } | is-empty) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let status = git --no-optional-locks status --porcelain=2 --branch | lines
|
||||||
|
|
||||||
|
let head = $status | where ($it | str starts-with '# branch.head') | str join | parse '# branch.head {branch}' | get branch | first
|
||||||
|
let result = [$"(ansi magenta2a)($head)"];
|
||||||
|
|
||||||
|
let ahead_behind = $status | where ($it | str starts-with '# branch.ab') | str join | parse "# branch.ab +{ahead} -{behind}"
|
||||||
|
let ahead = $ahead_behind | get ahead | first
|
||||||
|
let behind = $ahead_behind | get behind | first
|
||||||
|
let ahead = if ($ahead != '0') { $"↑($ahead)" } else {}
|
||||||
|
let behind = if ($behind != '0') { $"↓($behind)" } else {}
|
||||||
|
let result = $result | append ([$ahead, $behind] | where not ($it | is-empty) | str join (char space))
|
||||||
|
|
||||||
|
let untracked = $status | where ($it | str starts-with '?') | length
|
||||||
|
let unstaged = $status | where ($it =~ '1 \..+' ) | length
|
||||||
|
let staged = $status | where ($it =~ '1 .\..+' ) | length
|
||||||
|
let file_states = file_state_to_string [
|
||||||
|
[value, str, color];
|
||||||
|
[$untracked, $"…($untracked)", (ansi paleturquoise1)],
|
||||||
|
[$unstaged, $"✚($unstaged)", (ansi orange3)],
|
||||||
|
[$staged, $"●($staged)", (ansi darkseagreen1b)]
|
||||||
|
]
|
||||||
|
let result = $result | append $file_states
|
||||||
|
|
||||||
|
let result = $result | where not ($it | is-empty) | str join $" (ansi reset)"
|
||||||
|
$"(ansi lub)\(($result)(ansi lub)\)"
|
||||||
|
}
|
||||||
|
|
||||||
|
def file_state_to_string [$states: table] -> string {
|
||||||
|
$states | each {|itm|
|
||||||
|
if ($itm.value != 0) {
|
||||||
|
let str = $itm.str
|
||||||
|
let color = $itm.color
|
||||||
|
$"($color)($str)"
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
} | where not ($it | is-empty) | str join ' '
|
||||||
|
}
|
||||||
|
|
||||||
def create_left_prompt [] {
|
def create_left_prompt [] {
|
||||||
let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) {
|
let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) {
|
||||||
null => $env.PWD
|
null => $env.PWD
|
||||||
|
@ -9,19 +53,24 @@ def create_left_prompt [] {
|
||||||
$relative_pwd => ([~ $relative_pwd] | path join)
|
$relative_pwd => ([~ $relative_pwd] | path join)
|
||||||
}
|
}
|
||||||
|
|
||||||
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold })
|
let path_color = (if (is-admin) { ansi red_bold } else { ansi pb })
|
||||||
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold })
|
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi pb })
|
||||||
let path_segment = $"($path_color)($dir)"
|
let user_color = (if (is-admin) {ansi red} else { ansi xterm_magenta1 })
|
||||||
|
let path_segment = $"($user_color)[($env.USER)] ($path_color)($dir)(git_prompt)"
|
||||||
|
|
||||||
$path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)"
|
$path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def hostname [] -> string {
|
||||||
|
$"(ansi lmi)((sys).host | get hostname)(ansi reset)"
|
||||||
|
}
|
||||||
|
|
||||||
def create_right_prompt [] {
|
def create_right_prompt [] {
|
||||||
# create a right prompt in magenta with green separators and am/pm underlined
|
# create a right prompt in magenta with green separators and am/pm underlined
|
||||||
let time_segment = ([
|
let time_segment = ([
|
||||||
(ansi reset)
|
(ansi reset)
|
||||||
(ansi magenta)
|
(ansi magenta)
|
||||||
(date now | format date '%x %X') # try to respect user's locale
|
(date now | format date '%H:%M') # try to respect user's locale
|
||||||
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
|
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
|
||||||
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")
|
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}")
|
||||||
|
|
||||||
|
@ -31,7 +80,7 @@ def create_right_prompt [] {
|
||||||
] | str join)
|
] | str join)
|
||||||
} else { "" }
|
} else { "" }
|
||||||
|
|
||||||
([$last_exit_code, (char space), $time_segment] | str join)
|
([$last_exit_code, (hostname), $time_segment] | str join (char space))
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use nushell functions to define your right and left prompt
|
# Use nushell functions to define your right and left prompt
|
||||||
|
|
Loading…
Reference in New Issue