Git Product home page Git Product logo

nerdps1's Introduction

nerdps1

Nerd prompt for bash/ksh/zsh (mksh/ash)

activate the prompt

For better experience, install Nerd font on your system/console (Windows console / Windows terminal / putty / git-bash / CmdEr / iTerm2 / Terminator / MobaXterm / VScode terminal / Pycharm terminal...):
Consolas NF
Nerd Fonts

on Unix, copy to ~/.fonts and run fc-cache -fv then relaunch your terminal and set the font

Then activate the nerdps1 prompt:

$ . <(curl -s https://raw.githubusercontent.com/joknarf/nerdps1/main/nerdps1)
image

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

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
$ 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

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
$ 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

  • Overriding user login profile at ssh connexion with nerdps1 download

$ ssh -t <remote> '. <(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 <option>
    <option>: 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 myfunc2

You can add custom colorized segment defining ps1_addon() function:

  • ps1_addon() { pgrep rsyslogd >/dev/null || echo 'red:syslog'; } output format of function: <bgcolor>[/<fgcolor>/<sepcolor>]:<message>[|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 <color>:<text> else only <text>
  • right alignment separator : |
  • ps1_powerline="(/auto:exit_status (/blue:userhost )/auto:git_branch )/lblack:cwd > | (/lblue/black/blue:info (/auto:freemem (/blue:time )" image
  • ps1_powerline="auto:exit_status blue:userhost >/auto:git_branch >/lblack:cwd > | </lblue/black/blue:info </auto:freemem </blue:time" image

color theme example

used terminal colors in example:

        {
            "name": "NerdPS1",
            "background": "#000000",
            "foreground": "#D3D7CF",
            "black": "#000000",
            "blue": "#2760AA",
            "cyan": "#06989A",
            "green": "#088A5B",
            "purple": "#4c3d80",
            "red": "#BA1611",
            "white": "#D3D7CF",
            "yellow": "#CF8700",
            "brightBlack": "#243C4F",
            "brightBlue": "#729FCF",
            "brightCyan": "#34E2E2",
            "brightGreen": "#59c566",
            "brightPurple": "#AD7FA8",
            "brightRed": "#EF2929",
            "brightWhite": "#EEEEEC",
            "brightYellow": "#FCE94F"
        }

nerdps1's People

Contributors

joknarf avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

nerdps1's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.