1
0
Fork
You've already forked statusline
0
forked from sylfn/statusline
Beautiful and fast bash PS1
  • Rust 98.2%
  • Shell 1.5%
  • Nix 0.3%
2025年11月15日 05:00:02 +03:00
src "ptsd from stacked borrows" 2025年11月15日 05:00:02 +03:00
.gitignore initial commit 2023年07月18日 18:13:54 +03:00
.mailmap add mailmap 2024年10月07日 17:01:30 +03:00
Cargo.lock Simplify ANSI styling via wrapping Formatters 2025年11月15日 03:40:25 +03:00
Cargo.toml Simplify ANSI styling via wrapping Formatters 2025年11月15日 03:40:25 +03:00
COPYING.Apache-2.0 Use more free license 2024年09月10日 10:01:44 +03:00
COPYING.MIT Use more free license 2024年09月10日 10:01:44 +03:00
default.nix Use rust from nixpkgs (unstable); disable nightly 2025年09月10日 18:30:02 +03:00
README.md Fix readme 2025年10月30日 23:19:28 +03:00

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
  • Git, for repo information
  • Cargo, for installing and updating or Nix, for building

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. 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 'source <(statusline env)' >> ~/.bashrc
    
  6. 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)

Use in NixOS:

programs.bash.promptInit = let
 statusline = pkgs.callPackage pins.statusline {};
in ''
 PS1_MODE=minimal source <(${statusline}/bin/statusline env)
'';
programs.bash.vteIntegration = false;

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 and help further differentiate between devices
  • Build tools display to inform which commands can be executed to "make" the project in working directory. Makefile, ./configure, CMake, purplesyringa's ./jr, meson, nix 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 <Tab> 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 <return-code>] --jobs-count <jobs-count> [--elapsed-time <elapsed-time>] [--control-fd <control-fd>] [--mode <mode>]
 Print statusline as PS1 prompt. Is not meant to be invoked directly, however--
 Expects control-fd to exist, will kill itself when something passed to it
statusline colorize --what <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