diff --git a/prompt/README.md b/prompt/README.md index aae382d..60a9118 100644 --- a/prompt/README.md +++ b/prompt/README.md @@ -3,3 +3,25 @@ ### Definition These scripts should be used to draw a custom command prompt in nushell. They can include anything that we think is appropriate for prompts such as `git` commands, `starship`, `oh-my-posh`, etc. + +#### starship.nu + +File is in [starship](./starship.nu) + +This discribe how to use starship to make a leftprompt, the repo of starship is [here](https://github.com/starship/starship). + +This script set the output of starship as leftprompt + +![starshipshow](./images/starship.png) + +#### shell_space.nu + +File is in [shell_space](./shell_space.nu) + +Use the function of shells in nu, you can view the fucntion with the command following + +``` +help shells +``` + +![shell_spaceshow](./images/shell_space.png) diff --git a/prompt/images/shell_space.png b/prompt/images/shell_space.png new file mode 100644 index 0000000..63f856d Binary files /dev/null and b/prompt/images/shell_space.png differ diff --git a/prompt/images/starship.png b/prompt/images/starship.png new file mode 100644 index 0000000..0837a75 Binary files /dev/null and b/prompt/images/starship.png differ diff --git a/prompt/shell_space.nu b/prompt/shell_space.nu new file mode 100644 index 0000000..7a810ce --- /dev/null +++ b/prompt/shell_space.nu @@ -0,0 +1,21 @@ +# use shells to to show workspaces +def workspaces [] { + shells | each {|item index| + if $item.active { + $"(ansi green)($index) " + } else { + $"(ansi blue)($index) " + } + }| str collect +} + +def create_right_prompt [] { + let time_segment = ([ + (date now | date format '%r'), + " ", + (workspaces) + ] | str collect) + $time_segment +} + +let-env PROMPT_COMMAND_RIGHT = { create_right_prompt } diff --git a/prompt/starship.nu b/prompt/starship.nu new file mode 100644 index 0000000..86dbb9c --- /dev/null +++ b/prompt/starship.nu @@ -0,0 +1,11 @@ +def create_left_prompt [] { + ^starship prompt --cmd-duration $env.CMD_DURATION_MS $'--status=($env.LAST_EXIT_CODE)' +} + +let-env PROMPT_COMMAND = { create_left_prompt } + +# avoid same PROMPT_INDICATOR +let-env PROMPT_INDICATOR = { "" } +let-env PROMPT_INDICATOR_VI_INSERT = { ": " } +let-env PROMPT_INDICATOR_VI_NORMAL = { "〉" } +let-env PROMPT_MULTILINE_INDICATOR = { "::: " }