# nerdps1 Transportable Nerd prompt for bash/ksh/zsh (mksh/ash) *New: you should now use [joknarf/thefly](https://github.com/joknarf/thefly) plugin manager with [joknarf/nerdp](https://github.com/joknarf/nerdp) plugin, which is better implementation and can teleport all you shell environment/plugins through sudo/ssh to keep all your settings on all servers/users without touching their actual configuration* see also: [joknarf/shell-ng](https://github.com/joknarf/shell-ng) plugins compilation to get a full new shell experience (includes joknarf/nerdp prompt plugin) ## 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` image 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