#git-status #shell-prompt #bash #prompt #command-line #git-repository

nightly bin+lib statusline

Simple and fast bash PS1 line with useful features

43 releases (18 breaking)

0.19.1 Oct 27, 2024
0.18.3 Oct 2, 2024
0.17.4 Jul 28, 2024
0.16.0 Feb 19, 2024
0.2.2 Jul 25, 2023

#432 in Command line utilities

Download history 67/week @ 2024-08-01 172/week @ 2024-08-22 31/week @ 2024-08-29 299/week @ 2024-09-12 21/week @ 2024-09-19 233/week @ 2024-09-26 144/week @ 2024-10-03 17/week @ 2024-10-10 197/week @ 2024-10-24 31/week @ 2024-10-31

228 downloads per month

MIT/Apache and CC-PDDC licenses

110KB
2.5K SLoC

statusline

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

Requirements

  • Linux-compatible OS. Other OSes were not tested, but it will probably fail to run
  • Bash, for the shell
  • (Optional) Git, for repo information
  • (Optional for x86) SSSE3 support or better (prefer AVX2)
  • Cargo, for installing and updating

Installation

  1. Install rustup and nightly rust.

    pacman -S rustup
    rustup toolchain add nightly
    

    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 +nightly 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. 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
    
  5. Install the statusline to shell

    echo 'eval "$(statusline --env)"' >> ~/.bashrc
    
  6. Apply changes immediately

    source ~/.bashrc
    

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

You may wish to add RUSTFLAGS="-C target-feature=+avx2" to cargo install statusline for packaging and distributing reasons. For simple uses, this may be ignored as statusline compiles itself for current machine by default to maximize possible speed without throwing random SIGILL.

Features

  • Colorized username and hostname to prevent confusion if this statusline is installed on more than one device --- especially if connecting over SSH. Red color is reserved for root user
  • Git status display which immediately display repo's "persistent" info along with current state (rebasing, merging, etc.), and almost immediately the status. In addition, part of the working directory path inside the most nested git repo is highlighted
  • Chassis icons to display the type of the host device, which are acquired as fast as systemd does
  • Build tools display to inform which commands can be executed to "make" the project in working directory. Makefile, ./configure, CMake, purplesyringa's ./jr, qbs, qmake and cargo are supported
  • Simplified homes to make path more informative. Current user's home becomes ~, others' become ~username. Some paths are ignored to not make any confusion
  • ...and others like "readonly" display, exit code visualization, jobs count and prompt time

How is this different from purplesyringa's shell?

  • Small. It relies on a small amount of external libraries --- compared to a great lot of dependencies in "shell". Executable size is lesser than a megabyte with libc as its only dependency
  • Fast, even on slow devices. I remember waiting more than 5 seconds before the prompt appeared with "shell". I have patched it to show at least something useful before "heavy" data arrives. But I was surprised that in less than a quarter of second I've got almost the same info with this
  • Maintained. Only two people used purplesyringa's shell: me and her. After my disappointment with "shell"'s speed, I've started working on this project and she abandoned her one in favor of this one
  • Lesser bugs. "kill: no process found", "why does pressing make newer prompts broken", and some others --- are not present here by design
  • More icons. Almost every icon was changed to more appropriate and clean one
  • Nicer git status. Proper commit abbreviation, handling of "detached head", icons even here... I just had a sleepless night that day

Command line options

statusline
    Display simple message "how to use". Useless, but may be used to check if statusline is in path
statusline --env
    Print commands for `.bashrc`
statusline --run [return_code:N/A [jobs_count:0 [elapsed_time:N/A]]]
    Print statusline as PS1 prompt. Is not meant to be invoked directly, however---
    Expects third fd to exist, will kill itself when something passed to it
statusline --colorize <str>
    Colorize <str> like hostname and username. Can be used to choose hostname which has the color
    you want

This should have some better formatting but I'm too lazy for this

Dependencies

~10–19MB
~283K SLoC