2024-11-30 08:46:14 +00:00
# PrettyPrompt
2024-08-13 21:32:52 +00:00
2024-11-30 08:46:14 +00:00
A pretty shell prompt, written in rust
## Current Features
- **User indicator** - Symbol with different colors for root user and normal users
- **Error indicator** - Symbol with different colors to indicate if the last comment was successful
- **Git repo indicator**
- Indicates if the current directory is a repo or a regular directory
- Branches indicated by different colors
- **SSH indicator** - Symbol to indicate if the current shell is in an SSH session
- **Current directory**
- Abbreviated if the path is too long
- Replaces the user's home directory with a `~` symbol
- Show the repo's name if currently in a git repo
2024-08-18 05:49:59 +00:00
## Screenshot
![screenshot ](https://git.candifloss.cc/candifloss/PrettyPrompt/raw/branch/main/screenshot/BashPromptExampleScreenshoot.png "Screenshot" )
2024-11-30 08:46:14 +00:00
## Planned Features
2024-11-30 11:17:36 +00:00
- Right-hand side prompt: Implementing this is a challenge on non-`zsh` shells
2024-11-30 08:46:14 +00:00
- Configuration file
- Choose only the components you need
- Change appearance
- symbols and texts
- colors
- order and position
- Etc.
- User-defined components
2024-11-30 11:17:36 +00:00
- Static symbols or strings
2024-11-30 08:46:14 +00:00
- Shell symbol
- Host name
- Etc.
- Dynamic components by running custom commands
- Time & date
- More `git` information
- System stats
- Basically, anything you like
## Current Limitations
- Not user-configurable, yet - any changes in the current stage require hard-coding.
- Exit code of the last command requires to be passed as a command-line argument.
2024-11-30 11:17:36 +00:00
## Tested on
Ubuntu 24.04
- `bash` 5.2
- `zsh` 5.9
- `ion` 1.0.0-alpha
## Installation
1. Download the pre-built binary from [releases ](https://git.candifloss.cc/candifloss/PrettyPrompt/releases ), or build from source:
```bash
git clone https://git.candifloss.cc/candifloss/PrettyPrompt.git
cd PrettyPrompt/
cargo build --release #Now find the `prettyprompt` binary in `target/release/`
```
2. Move the binary to a path in your `$PATH` . Eg:
```bash
sudo mv /path/to/prettyprompt /usr/bin/
```
Or add it to your `$PATH` variable by adding this to your `bashrc` , `zshrc` , or `ion/initrc`
```bash
export PATH="$PATH:/your/path"
```
2024-11-30 08:46:14 +00:00
## Usage
2024-11-30 11:17:36 +00:00
The binary needs to be in your `$PATH` . Place it somewhere like `/usr/bin/` , or add the appropriate path to the `$PATH` variable.
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.
2024-11-30 08:46:14 +00:00
### `bash`
2024-11-30 11:17:36 +00:00
- The `PS1` variable sets a fixed prompt string.
- This `PROMPT_COMMAND` variable updates the prompt every time.
System-wide: `/etc/bash.bashrc` , or User-specific: `$HOME/.bashrc` :
2024-11-30 08:46:14 +00:00
```bash
2024-11-30 11:17:36 +00:00
PS1="" # Set it to an empty string
PROMPT_COMMAND='prettyprompt $?' # Single quotes, not double quotes
2024-11-30 08:46:14 +00:00
```
### `ion`
2024-11-30 11:17:36 +00:00
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` :
2024-11-30 08:46:14 +00:00
```ion
fn PROMPT
prettyprompt $?
end
```
2024-11-30 11:17:36 +00:00
### `zsh`
Export the `PS1` variable with the output of `prettyprompt $?` as its value.
User-specific: `$HOME/.zshrc` , System-wide: `/etc/zsh/zshrc` :
```zsh
export PS1='$(prettyprompt $?)'
```
2024-11-30 08:46:14 +00:00
## Changes since the last version
- **Updated Output String Type:** Improved compatibility with other shells.
- **Revamped Indicator Symbols:** Enhanced the visual aspect of the prompt.
- **Removed Shell Symbol:** Determining the shell is practically not possible.
- **Conditional Component Inclusion:** A first step towards user-configuration expected in future versions.
- **Code Improvements:** readability and performance
- **Refactoring:** Modular structure for better readability and maintenance.
- **Modularization:** Separate modules for cleaner organization.
- **Error Handling:** Improved logic to exclude error messages from the prompt.
- **Enhanced Documentation:** Comments for better comprehension.
2024-11-30 11:17:36 +00:00
## Acknowledgement
The current default(and only) theme is inspired by [s1ck94 ](https://github.com/zimfw/s1ck94 ) theme from [zimfw ](https://zimfw.sh/ ).