statusline 0.22.0

Simple and fast bash PS1 line with useful features
statusline-0.22.0 is not a library.
Visit the last successful build: statusline-0.21.0

statusline

A blazingly-fast[^fast] successor to purplesyringa's shell, rewritten in Rust.

[^fast]: compared to shell, but this claim was made off general vibes and might have been wrong. It is probably faster, though not by that much.

TODO: maybe some screenshots to show what it's like?

Requirements

  • a decently modern linux kernel
  • bash, obviously
  • git binary (optional, recommended)
  • cargo or nix
  • a little bit of time and patience

Installation

  1. Install rustup and stable rust.

    pacman -S rustup
    rustup toolchain add stable
    

    Visit rustup.rs if not on Arch-based distro to see how to install on other distros. You may need to run rustup installation with superuser rights

  2. Install statusline from cargo

    cargo install statusline
    
  3. Check if statusline is in path.

    statusline
    

    If "bash: statusline: command not found" is shown, check your $PATH and ~/.bashrc, a folder where cargo install placed statusline binary should be there.

    If you wish to not add the directory to $PATH, you can just use full path instead of short one in statusline env below

  4. Set preferred statusline icons' mode.

  5. Do not add this line for defaults! Available modes are:

    • PS1_MODE=text: use ASCII text instead of icons
    • PS1_MODE=minimal: use alternative icon set which is somewhat simpler but may be perplexing
    • otherwise: use default nerdfont icons
    echo 'export PS1_MODE=minimal' >> ~/.bashrc
    
  6. Install the statusline to shell

    echo 'source <(statusline env)' >> ~/.bashrc
    
  7. Apply changes immediately

    PS1_MODE=minimal source <(statusline env)
    

Don't forget to check $PATH and update from time to time.

Nix way

Build and apply immediately:

nix-build --log-format multiline-with-logs && source <(result/bin/statusline env)

NixOS usage example can be found in my configuration.

Features

Like any fancy PS1, this one supports color. It detects tmux and tty and resets itself to text-friendly mode, and also detects terminals that call themselves dumb and doesn't modify PS1 in that case at all.

statusline simplifies displayed paths. /home/<yourusername> becomes ~, and /home/<another> becomes ~another, like bash tilde expansion, but in reverse.

statusline integrates with Git and is able to show basic information about repositories it encounters even without git binary present.

One notable feature, though, is colorized hostnames, usernames and git branches. They get assigned a random color and it helps differentiate between hosts, users and branches. The color red is reserved for root. The colors displayed are "true" (24-bit), meaning that tty or other lesser-color terminals may collide some colors and revert the disambiguation.

None of the colors and format strings are customizable, but the order of them is (or will be soon).

How is this different from purplesyringa's shell?

There once was a bashful list of why one should use this version over the bash one, but the gist of it is that the bash version was slow, unmaintained, buggy, and a maintenance burden.

Command line options

  • statusline (without args)

    Shows the version, link to the repo, and a simple how-to-use message.

  • statusline [command] --help or statusline help [command]

    Shows help messages.

  • statusline env

    Prints contents of what's executed by recommended bashrc snippet.

  • statusline run [--return-code <c>] --jobs-count <j> [--elapsed-time <t>] [--control-fd <f>] [--mode <m>]

    This command is run by bash at every PS1 instantiation. One can run it without bash to profile the prompt, or to see how the PS1 would look without installing PS1 into the shell.

  • statusline create, statusline chain and ssh alias

    Undocumented ssh workgroup feature. Never got to documenting it, basically.