forked from carapace-sh/carapace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
747 additions
and
823 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,62 +1,78 @@ | ||
# Nushell Environment Config File | ||
# | ||
# version = "0.85.0" | ||
|
||
def create_left_prompt [] { | ||
let path_segment = if (is-admin) { | ||
$"(ansi red_bold)($env.PWD)" | ||
} else { | ||
$"(ansi green_bold)($env.PWD)" | ||
} | ||
let home = $nu.home-path | ||
|
||
let dir = ([ | ||
($env.PWD | str substring 0..($home | str length) | str replace $home "~"), | ||
($env.PWD | str substring ($home | str length)..) | ||
] | str join) | ||
|
||
let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) | ||
let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) | ||
let path_segment = $"($path_color)($dir)" | ||
|
||
$path_segment | ||
$path_segment | str replace --all (char path_sep) $"($separator_color)/($path_color)" | ||
} | ||
|
||
def create_right_prompt [] { | ||
# create a right prompt in magenta with green separators and am/pm underlined | ||
let time_segment = ([ | ||
(date now | date format '%m/%d/%Y %r') | ||
(ansi reset) | ||
(ansi magenta) | ||
(date now | format date '%x %X %p') # try to respect user's locale | ||
] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" | | ||
str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}") | ||
|
||
let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ | ||
(ansi rb) | ||
($env.LAST_EXIT_CODE) | ||
] | str join) | ||
} else { "" } | ||
|
||
$time_segment | ||
([$last_exit_code, (char space), $time_segment] | str join) | ||
} | ||
|
||
# Use nushell functions to define your right and left prompt | ||
let-env PROMPT_COMMAND = { create_left_prompt } | ||
let-env PROMPT_COMMAND_RIGHT = { create_right_prompt } | ||
$env.PROMPT_COMMAND = {|| create_left_prompt } | ||
# FIXME: This default is not implemented in rust code as of 2023-09-08. | ||
$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } | ||
|
||
# The prompt indicators are environmental variables that represent | ||
# the state of the prompt | ||
let-env PROMPT_INDICATOR = { "〉" } | ||
let-env PROMPT_INDICATOR_VI_INSERT = { ": " } | ||
let-env PROMPT_INDICATOR_VI_NORMAL = { "〉" } | ||
let-env PROMPT_MULTILINE_INDICATOR = { "::: " } | ||
$env.PROMPT_INDICATOR = {|| "> " } | ||
$env.PROMPT_INDICATOR_VI_INSERT = {|| ": " } | ||
$env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " } | ||
$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } | ||
|
||
# Specifies how environment variables are: | ||
# - converted from a string to a value on Nushell startup (from_string) | ||
# - converted from a value back to a string when running external commands (to_string) | ||
# Note: The conversions happen *after* config.nu is loaded | ||
let-env ENV_CONVERSIONS = { | ||
"PATH": { | ||
from_string: { |s| $s | split row (char esep) | path expand -n } | ||
to_string: { |v| $v | path expand -n | str join (char esep) } | ||
} | ||
"Path": { | ||
from_string: { |s| $s | split row (char esep) | path expand -n } | ||
to_string: { |v| $v | path expand -n | str join (char esep) } | ||
} | ||
$env.ENV_CONVERSIONS = { | ||
"PATH": { | ||
from_string: { |s| $s | split row (char esep) | path expand --no-symlink } | ||
to_string: { |v| $v | path expand --no-symlink | str join (char esep) } | ||
} | ||
"Path": { | ||
from_string: { |s| $s | split row (char esep) | path expand --no-symlink } | ||
to_string: { |v| $v | path expand --no-symlink | str join (char esep) } | ||
} | ||
} | ||
|
||
# Directories to search for scripts when calling source or use | ||
# | ||
# By default, <nushell-config-dir>/scripts is added | ||
let-env NU_LIB_DIRS = [ | ||
($nu.config-path | path dirname | path join 'scripts') | ||
$env.NU_LIB_DIRS = [ | ||
# FIXME: This default is not implemented in rust code as of 2023-09-06. | ||
($nu.default-config-dir | path join 'scripts') # add <nushell-config-dir>/scripts | ||
] | ||
|
||
# Directories to search for plugin binaries when calling register | ||
# | ||
# By default, <nushell-config-dir>/plugins is added | ||
let-env NU_PLUGIN_DIRS = [ | ||
($nu.config-path | path dirname | path join 'plugins') | ||
$env.NU_PLUGIN_DIRS = [ | ||
# FIXME: This default is not implemented in rust code as of 2023-09-06. | ||
($nu.default-config-dir | path join 'plugins') # add <nushell-config-dir>/plugins | ||
] | ||
|
||
# To add entries to PATH (on Windows you might use Path), you can use the following pattern: | ||
# let-env PATH = ($env.PATH | split row (char esep) | prepend '/some/path') | ||
# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') |
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 |
---|---|---|
@@ -1,39 +1,39 @@ | ||
let-env STARSHIP_SHELL = "nu" | ||
let-env STARSHIP_SESSION_KEY = (random chars -l 16) | ||
let-env PROMPT_MULTILINE_INDICATOR = (^/usr/local/bin/starship prompt --continuation) | ||
# this file is both a valid | ||
# - overlay which can be loaded with `overlay use starship.nu` | ||
# - module which can be used with `use starship.nu` | ||
# - script which can be used with `source starship.nu` | ||
export-env { load-env { | ||
STARSHIP_SHELL: "nu" | ||
STARSHIP_SESSION_KEY: (random chars -l 16) | ||
PROMPT_MULTILINE_INDICATOR: ( | ||
^/usr/bin/starship prompt --continuation | ||
) | ||
# Does not play well with default character module. | ||
# TODO: Also Use starship vi mode indicators? | ||
let-env PROMPT_INDICATOR = "" | ||
# Does not play well with default character module. | ||
# TODO: Also Use starship vi mode indicators? | ||
PROMPT_INDICATOR: "" | ||
let-env PROMPT_COMMAND = { | ||
# jobs are not supported | ||
let width = (term size).columns | ||
^/usr/local/bin/starship prompt $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" | ||
} | ||
|
||
# Whether we can show right prompt on the last line | ||
let has_rprompt_last_line_support = (version).version >= 0.71.0 | ||
|
||
# Whether we have config items | ||
let has_config_items = (not ($env | get -i config | is-empty)) | ||
|
||
if $has_rprompt_last_line_support { | ||
let config = if $has_config_items { | ||
$env.config | upsert render_right_prompt_on_last_line true | ||
} else { | ||
{render_right_prompt_on_last_line: true} | ||
PROMPT_COMMAND: {|| | ||
# jobs are not supported | ||
( | ||
^/usr/bin/starship prompt | ||
--cmd-duration $env.CMD_DURATION_MS | ||
$"--status=($env.LAST_EXIT_CODE)" | ||
--terminal-width (term size).columns | ||
) | ||
} | ||
{config: $config} | ||
} else { | ||
{ } | ||
} | load-env | ||
|
||
let-env PROMPT_COMMAND_RIGHT = { | ||
if $has_rprompt_last_line_support { | ||
let width = (term size).columns | ||
^/usr/local/bin/starship prompt --right $"--cmd-duration=($env.CMD_DURATION_MS)" $"--status=($env.LAST_EXIT_CODE)" $"--terminal-width=($width)" | ||
} else { | ||
'' | ||
config: ($env.config? | default {} | merge { | ||
render_right_prompt_on_last_line: true | ||
}) | ||
|
||
PROMPT_COMMAND_RIGHT: {|| | ||
( | ||
^/usr/bin/starship prompt | ||
--right | ||
--cmd-duration $env.CMD_DURATION_MS | ||
$"--status=($env.LAST_EXIT_CODE)" | ||
--terminal-width (term size).columns | ||
) | ||
} | ||
} | ||
}} |
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,3 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [rsteube] |
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
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
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
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
Oops, something went wrong.