mirror of
https://github.com/RGBCube/nu_scripts
synced 2025-08-01 22:57:46 +00:00
feat: add example for starship and shell_space (#320)
This commit is contained in:
parent
8aec0bcc57
commit
3451c3f0e0
5 changed files with 54 additions and 0 deletions
|
@ -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
|
||||
|
||||

|
||||
|
||||
#### 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
|
||||
```
|
||||
|
||||

|
||||
|
|
BIN
prompt/images/shell_space.png
Normal file
BIN
prompt/images/shell_space.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.2 KiB |
BIN
prompt/images/starship.png
Normal file
BIN
prompt/images/starship.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
21
prompt/shell_space.nu
Normal file
21
prompt/shell_space.nu
Normal file
|
@ -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 }
|
11
prompt/starship.nu
Normal file
11
prompt/starship.nu
Normal file
|
@ -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 = { "::: " }
|
Loading…
Add table
Add a link
Reference in a new issue