updated README

This commit is contained in:
Candifloss 2024-12-01 18:31:07 +05:30
parent 6766711122
commit d9fdd8fa9e

View File

@ -21,29 +21,21 @@ A pretty shell prompt, written in rust
## Planned Features ## Planned Features
- Right-hand side prompt: Implementing this is a challenge on non-`zsh` shells - **Right-hand side prompt**: Challenging to implement on non-zsh shells.
- Configuration file - **Configuration file**
- Choose only the components you need - Choose only the components you need
- Change appearance - Change appearance
- symbols and texts - Symbols and text
- colors - Colors
- order and position - Order and position
- Etc. - Custom components
- User-defined components - Static: Shell icon, Host name, etc.
- Static symbols or strings - Dynamic: Time &date, system stats, or any custom commands
- Shell symbol
- Host name
- Etc.
- Dynamic components by running custom commands
- Time & date
- More `git` information
- System stats
- Basically, anything you like
## Current Limitations ## Current Limitations
- Not user-configurable, yet - any changes in the current stage require hard-coding. - **Hard-Coded Configuration**: User customization is not available yet.
- Exit code of the last command requires to be passed as a command-line argument. - **Exit Code Requirement**: Must pass the last commands exit code as a command-line argument.
## Tested on ## Tested on
@ -54,33 +46,41 @@ Ubuntu 24.04
## Installation ## Installation
1. Download the pre-built binary from [releases](https://git.candifloss.cc/candifloss/PrettyPrompt/releases), or build from source: **Step 1. Get the binary**
- Option 1. Download the pre-built binary from the [releases page](https://git.candifloss.cc/candifloss/PrettyPrompt/releases).
- Option 2. Build from source(if you have [rust](https://www.rust-lang.org/tools/install) installed):
```bash ```bash
git clone https://git.candifloss.cc/candifloss/PrettyPrompt.git git clone https://git.candifloss.cc/candifloss/PrettyPrompt.git
cd PrettyPrompt/ cd PrettyPrompt/
cargo build --release #Now find the `prettyprompt` binary in `target/release/` cargo build --release
# Binary location: `target/release/prettyprompt`
``` ```
2. Move the binary to a path in your `$PATH`. Eg:
**Step 2. Add to `$PATH`**
- Option 1. Move the binary to a directory in your `$PATH`. Eg:
```bash ```bash
sudo mv /path/to/prettyprompt /usr/bin/ sudo mv /path/to/prettyprompt /usr/bin/
``` ```
Or add it to your `$PATH` variable by adding this to your `bashrc`, `zshrc`, or `ion/initrc` - Option 2. Add the directory containing the binary to `$PATH`
System-wide: `/etc/profile`
User-specific: `~/.profile`
Shell-specific: `bashrc`, `zshrc`, etc.
```bash ```bash
export PATH="$PATH:/your/path" export PATH="$PATH:/path/where/the/binary/is/"
``` ```
## Usage ## Usage
The binary needs to be in your `$PATH`. Place it somewhere like `/usr/bin/`, or add the appropriate path to the `$PATH` variable. Configuration varies by shell, and the file location varies by distro. Consult your shell's docs or community resources for details. Note that the exit code of the last command(usually `$?` variable) must be passed as a command-line argument.
The configuration depends on the shell, and the file location can vary according to your distro. Please consult the documentations or forums of your shell for more accurate information.
### `bash` ### `bash`
- The `PS1` variable sets a fixed prompt string. - The `PS1` variable sets a fixed prompt string.
- This `PROMPT_COMMAND` variable updates the prompt every time. - This `PROMPT_COMMAND` variable updates the prompt every time.
System-wide: `/etc/bash.bashrc`, or User-specific: `$HOME/.bashrc`: System-wide: `/etc/bash.bashrc`
User-specific: `~/.bashrc`:
```bash ```bash
PS1="" # Set it to an empty string PS1="" # Set it to an empty string
PROMPT_COMMAND='prettyprompt $?' # Single quotes, not double quotes PROMPT_COMMAND='prettyprompt $?' # Single quotes, not double quotes
@ -88,8 +88,8 @@ PROMPT_COMMAND='prettyprompt $?' # Single quotes, not double quotes
### `ion` ### `ion`
The `PROMPT` function is currently the only way to customize the prompt according to the ion shell docs. The `PROMPT` function is currently the only way to customize the prompt according to the `ion` shell docs.
User-specific config file: `$HOME/.config/ion/initrc`: User-specific config: `~/.config/ion/initrc`:
```ion ```ion
fn PROMPT fn PROMPT
prettyprompt $? prettyprompt $?
@ -98,15 +98,20 @@ end
### `zsh` ### `zsh`
Export the `PS1` variable with the output of `prettyprompt $?` as its value. Export the `PS1` variable with the output of `prettyprompt $?` as its value.
User-specific: `$HOME/.zshrc`, System-wide: `/etc/zsh/zshrc`: User-specific: `~/.zshrc`
```zsh System-wide: `/etc/zsh/zshrc`
```sh
export PS1='$(prettyprompt $?)' export PS1='$(prettyprompt $?)'
``` ```
### Other shells
For other shells, refer their docs to set a dynamic prompt. Ensure the last command's exit code (`$?` or equivalent) is passed to `prettyprompt`.
## Changes since the last version ## Changes since the last version
- **Updated Output String Type:** Improved compatibility with other shells. - **Updated Output String Type:** Improved compatibility with other shells.
- **Revamped Indicator Symbols:** Enhanced the visual aspect of the prompt. - **Revamped Indicator Symbols:** Enhanced the visual aspect of the prompt.
- **Removed Shell Symbol:** Determining the shell is practically not possible. - **Removed Shell Icon:** Determining the shell is practically not possible.
- **Conditional Component Inclusion:** A first step towards user-configuration expected in future versions. - **Conditional Component Inclusion:** A first step towards user-configuration expected in future versions.
- **Code Improvements:** readability and performance - **Code Improvements:** readability and performance
- **Refactoring:** Modular structure for better readability and maintenance. - **Refactoring:** Modular structure for better readability and maintenance.
@ -116,4 +121,10 @@ export PS1='$(prettyprompt $?)'
## Acknowledgement ## Acknowledgement
The current default(and only) theme is inspired by [s1ck94](https://github.com/zimfw/s1ck94) theme from [zimfw](https://zimfw.sh/). The current default (and only) theme draws inspiration from [s1ck94](https://github.com/zimfw/s1ck94) theme of [zimfw](https://zimfw.sh/).
## Why this project?
- **Efficiency**: Avoids repeated invocation of multiple binaries like `tr`, `grep`, `echo`, `git`, `sed`, etc., which would otherwise be used dozens of times in shell scripts just to generate a colored string.
- **Universality**: Eliminates the need to write separate scripts in different shell languages for various shells.
- **Learning Rust**: Serves as a fun and practical project to learn and apply Rust programming skills.