Skip to content

Latest commit

 

History

History
90 lines (67 loc) · 2.39 KB

README.md

File metadata and controls

90 lines (67 loc) · 2.39 KB

libps1

libps1 is an experimental shell prompt for power users. There are many great shell prompt projects in existence, but this one is different. While nearly every other option uses some kind of configuration file (toml, yaml, etc), libps1 is intended to be used as a library, so it can be customized and documented using the incredible tooling developed by the Rust ecosystem. No more wondering what other options are available, or if you are spelling things correctly, your IDE and the compiler will guide you.

screenshot

Getting Started

Option 1 - binps1

binps1 is the reference shell prompt implementation, using libps1.

cargo install --force --path . --example binps1
# .bashrc

# default color scheme
PS1='$(binps1)'

# or pick one of the available custom color schemes
PS1='$(binps1 --theme solarized)'
# .zshrc

autoload -Uz add-zsh-hook
_prompt() {
	PS1="$(binps1 --theme solarized)"
}
add-zsh-hook precmd _prompt

Option 2 - Make it your own!

cargo new --bin my_shell # pick your own name here
# cargo.toml
[dependencies]
libps1 = { git = "https://github.com/JoshMcguigan/libps1" }
# main.rs

use libps1::{
    Color::{Green, Purple, Red, Yellow, RGB},
    Prompt,
};

/// This is a demonstration of a fully customized shell prompt
/// using libps1.
fn main() {
    Prompt {
        cwd_color: Purple,
        cwd_shorten_directories: false,
        cwd_shorten_home: Some("⌂"),

        git_branch_color: RGB(0x17, 0xC8, 0xB0),

        git_status_clean_color: Green,
        git_status_unstaged_color: Red,
        git_status_staged_color: Yellow,
        git_status_clean_icon: "➖",
        git_status_unstaged_icon: "❌",
        git_status_staged_icon: "➕",

        prompt_char_separator: "\n",
        // If you'd prefer not to specify all of the values, uncomment
        // the line below to fall back on a theme. And add the import
        // to the top of the file.
        //
        // use libps1::Theme::Solarized;
        // ..Prompt::with_theme(Solarized)
    }
    .show()
}

Then cargo install your binary and setup your .bashrc/.zshrc as shown in Option 1.

Related Projects

libps1 is a fork of pista by @NerdyPepper.