Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joknarf/nerdps1
Nerd powerline prompt for bash/ksh/zsh
https://github.com/joknarf/nerdps1
bash bashrc dynamic island ksh kshrc nerd-fonts powerline profile prompt ps1 shell shell-script term terminal zsh zshrc
Last synced: 4 days ago
JSON representation
Nerd powerline prompt for bash/ksh/zsh
- Host: GitHub
- URL: https://github.com/joknarf/nerdps1
- Owner: joknarf
- License: mit
- Created: 2023-05-06T12:27:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-30T23:36:17.000Z (14 days ago)
- Last Synced: 2024-10-31T00:24:24.934Z (14 days ago)
- Topics: bash, bashrc, dynamic, island, ksh, kshrc, nerd-fonts, powerline, profile, prompt, ps1, shell, shell-script, term, terminal, zsh, zshrc
- Language: Shell
- Homepage:
- Size: 127 KB
- Stars: 8
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nerdps1
Transportable Nerd prompt for bash/ksh/zsh (mksh/ash)*New: you can now use [thefly](https://github.com/joknarf/thefly) to teleport all you shell env/plugins*
## Font for prompt
For better experience, install a Nerd font on your system/console (Windows console / Windows terminal / putty / git-bash / CmdEr / iTerm2 / Terminator / MobaXterm / VScode terminal / Pycharm terminal...):
[Consolas NF](https://github.com/wclr/my-nerd-fonts/raw/master/Consolas%20NF/Consolas%20Nerd%20Font%20Complete%20Mono%20Windows%20Compatible.ttf)
[Nerd Fonts](https://www.nerdfonts.com/)on Unix, copy to `~/.fonts` and run `fc-cache -fv` then relaunch your terminal and set the font
## Installation
* You can install using a plugin manager like sheldon / zgenom ... : plugin joknarf/nerdps1
* Or you can activate the nerdps1 prompt directly using:
`$ . <(curl -s 'https://raw.githubusercontent.com/joknarf/nerdps1/main/nerdps1')`
* Or you can get your local copy using:
`$ curl -sL -o ~/nerdps1 'https://raw.githubusercontent.com/joknarf/nerdps1/main/nerdps1'`
then source it in your profile/rcfile:
`. ~/nerdps1`Following information displayed:
* exit code if command returns code is not 0
* elapse time during command if command lasts more than 1s (bash / zsh / ksh >2012)
* user@hostname
* current working directory
* git branch if in git directory (colorized according to git status)
* python VIRTUAL_ENV and other variables values with name in `ps1_info` variable
* filesystem usage check of `ps1_fslist` (default "/ /tmp") according to `ps1_fslimits` (default "95 100")
* 1min cpu load (colorized default `ps1_loadlimits` "10 20")
* Available memory (colorized default `ps1_memlimits` "300 100" MB)
* Time
## choose your style
set `ps1_style` variable to available styles in your .nerdrc
You can test using `ps1_style` function:![image](https://github.com/joknarf/nerdps1/assets/10117818/f8d32297-73f4-4827-9802-b635c9d9a481)
## persistent prompt across sudo
Using functions `psudo` you can login to other users keeping your nerdps1 prompt, and even add your environment file to source after user profile is loaded.
* `psudo` is reproducing full login of user according to its shell (/etc/profile .profile ...) and adds the nerdps1 and your optional custom env file
```shell
$ psudo user [myenvfile]
```
* psudo uses `sudo -u user` command
The login shell will be the user shell (must be one of bash/ksh/zsh)![image](https://user-images.githubusercontent.com/10117818/236661556-becd0184-4cb1-4b14-ab6c-5fc5c2f16f2e.png)
`psudo` can be used multiple times to forward the prompt/environment to users (psudo user1 followed by psudo user2...)
* psudo options:
* `-b` : use bash shell login instead of sudo user shell
* `-g` : don't load global profile (/etc/profile)
* `-u` : don't load user profile## persistent prompt across ssh connection
Using functions pssh and psshu you can connect to remote servers with your nerdps1 prompt, and even add your local environment file to source after user profile.
* `pssh/psshu` is reproducing full login of user according to its shell (/etc/profile .profile ...) and adds the nerdps1 and your optional custom env file```shell
$ pssh [user@]remote [myenvfile] [ssh options]
$ psshu [user@]remote [myenvfile] [ssh options]
```
* pssh will use local nerdps1 to make a copy to remote.
* psshu will use `$ps1_url` to download nerdps1.
Invocated shell is remote user shell (bash/ksh/zsh)`pssh\psshu` can be used multiple times to forward prompt/environment (can be mixed with `psudo` too)
* pssh/psshu options:
* `-b` : use bash shell login instead of remote user shell
* `-g` : don't load global profile (/etc/profile)
* `-u` : don't load user profile![image](https://user-images.githubusercontent.com/10117818/236662496-00aafc19-a253-4a2d-a356-df900b28324c.png)
* Overriding user login profile at ssh connexion with nerdps1 download
`$ ssh -t '. <(curl -s https://raw.githubusercontent.com/joknarf/nerdps1/main/nerdps1) login'`or in .ssh/config:
```
RequestTTY force
RemoteCommand . <(curl -s https://raw.githubusercontent.com/joknarf/nerdps1/main/nerdps1) login
```## using .nerdrc as your custom env file
Instead of passing custom env file, you can create a `~/.nerdrc` env file that will be automatically sourced after user profile and forwarded by psudo/pssh/psshu.
You can put all ps1_ variables to override nerdps1 defaults, and all functions/path/env settings you want to have everywhere !## /tmp full proof
nerdps1 will use /var/tmp if not enough space in /tmp. (ssh connections can occur even if /tmp full on remote)
## Font rendering
If your terminal does not manage correctly nerd font symbols, you may switch to more commonly supported powerline font symbols, or even disable the segment separator symbols.
You can use : `ps1_display` function/var to switch prompt display symbol characters:
```
$ ps1_display -h
usage: ps1_display
: nerdicons, nerd, powerline, nofont, ascii
```## Customizing prompt
You can add informations on the prompt using ps1_info variable:
* `ps1_info="MYVAR MYVAR2..."` : will display content of variables
* `ps1_info="(myfunc) (myfunc2)"` : will display output of functions myfunc myfunc2You can add custom colorized segment defining `ps1_addon()` function:
* `ps1_addon() { pgrep rsyslogd >/dev/null || echo 'red:syslog'; }`
output format of function:
`[//]:[|message]`
empty output discards the segment.Changing prompt powerline, ps1_powerline variable represents the prompt:
* segment setting : `symbol/bgcolor/fgcolor/sepcolor:function`
* function called is `ps1_function` (ps1_ prefixed)
* colors : `black red green yellow blue magenta cyan white`, prefix `l` for light color
* symbols : `< > ( )`
* when color is set to auto, the function output must be `:` else only ``
* right alignment separator : `|`
* `ps1_powerline="(/auto:exit_status (/blue:userhost )/auto:git_branch )/lblack:cwd > | (/lblue/black/blue:info (/auto:freemem (/blue:time )"`
![image](https://github.com/joknarf/nerdps1/assets/10117818/54fa6b66-03b5-4b04-8920-a461efcd9ca4)
* `ps1_powerline="auto:exit_status blue:userhost >/auto:git_branch >/lblack:cwd > |