An open API service indexing awesome lists of open source software.

https://github.com/info-mono/diyship-classic

๐Ÿงฐ๐Ÿš€ Cross-shell prompt CLI framework
https://github.com/info-mono/diyship-classic

basher bpkg cli crosh-shell diyship prompt starship terminal

Last synced: about 2 months ago
JSON representation

๐Ÿงฐ๐Ÿš€ Cross-shell prompt CLI framework

Awesome Lists containing this project

README

          


Cross-shell prompt framework


License: GPL-3.0 Development completed

## ๐Ÿ’ก About

**DIYship** is a cross-shell prompt framework written in [`portable sh`](https://github.com/dylanaraps/pure-sh-bible) that let you write your prompt with any programing language for any shell.

> _[Learn more about how its work](#%EF%B8%8F-configuration)._

## ๐Ÿš€ Setup

### ๐Ÿงพ Dependencies

- [`sh`](https://wikipedia.org/wiki/Bourne_shell) to process.
- [`date`](https://wikipedia.org/wiki/Unix_time) and [`cut`](https://wikipedia.org/wiki/Cut_(Unix)) for timing (required by Bash, Zsh, Elvish and Tcsh).
- [`wc`](https://wikipedia.org/wiki/Wc_(Unix)) for job counting (required by Ion).
- [`cat`](https://wikipedia.org/wiki/Cat_(Unix)) for return workaround (required by Xonsh).

### ๐Ÿ“ฅ Installation

#### ๐Ÿ”ง Manually

Option 1: using `curl`

```sh
curl https://raw.githubusercontent.com/info-mono/diyship-classic/main/bin/diyship > ~/.local/bin/diyship
chmod +x ~/.local/bin/diyship
```

Option 2: using `git`

```sh
git clone https://github.com/info-mono/diyship-classic.git ~/.local/share/diyship
ln -s ~/.local/share/diyship/bin/diyship ~/.local/bin/diyship
```

#### ๐Ÿ“ฆ Package manager

For [Bpkg](https://github.com/bpkg/bpkg) user:

```sh
bpkg install info-mono/diyship-classic
```

For [Basher](https://github.com/basherpm/basher) user:

```sh
basher install info-mono/diyship-classic
```

> _If you can and want to port DIYship to other package managers, feel free to do so._

## โŒจ๏ธ Usage

Add the init script to your shell's config file:

### ๐Ÿš Bash

Add the following to the end of `~/.bashrc`:

```bash
eval "$(diyship bash)"
```

### ๐Ÿš Zsh

Add the following to the end of `~/.zshrc`:

```zsh
eval "$(diyship zsh)"
```

### ๐Ÿš Fish

Add the following to the end of `~/.config/fish/config.fish`:

```fish
diyship fish | source
```

### ๐Ÿš PowerShell

Add the following to the end of `Microsoft.PowerShell_profile.ps1`.
You can check the location of this file by querying the `$PROFILE` variable in PowerShell.
Typically the path is `~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1` or `~/.config/powershell/Microsoft.PowerShell_profile.ps1` on `*nix`.

```powershell
Invoke-Expression (@(&diyship powershell) -join "`n")
```

### ๐Ÿš Ion

Add the following to the end of `~/.config/ion/initrc`:

```ion
eval $(diyship ion)
```

### ๐Ÿš Elvish

Add the following to the end of `~/.elvish/rc.elv`:

```elv
eval (diyship elvish | slurp)
```

> _Only Elvish v0.15 or higher is supported._

### ๐Ÿš Tcsh

Add the following to the end of `~/.tcshrc`:

```tcsh
eval `diyship tcsh`
```

### ๐Ÿš Nushell

Add the following to your Nushell config file. You can check the location of this file by running `config path` in Nushell.

```toml
startup = [
"mkdir ~/.cache/diyship",
"diyship nushell | save ~/.cache/diyship/init.nu",
"source ~/.cache/diyship/init.nu"
]

prompt = "diyship_prompt"
```

### ๐Ÿš Xonsh

Add the following to the end of `~/.xonshrc`:

```xsh
execx($(diyship xonsh))
```

> _Only Nushell version v0.33 or higher is supported._

## โš™๏ธ Configuration

DIYship is basically execute a command (which could be a path to an **executable** script file or program) and take it output as a prompt,
you can change the command through environment variable:

`export DIYSHIP_COMMAND_=""`

| Environment variable | Default | Description |
| ----------------------- | -------------------------------- | ------------------------------ |
| `DIYSHIP_COMMAND_LEFT` | `$XDG_CONFIG_HOME/diyship/left` | Command to print left prompt. |
| `DIYSHIP_COMMAND_RIGHT` | `$XDG_CONFIG_HOME/diyship/right` | Command to print right prompt. |

DIYship will export these following environment variables before running the commands to print out prompts,
so you could utilize theme informations in your script/program:

| Environment variable | Description |
| --------------------- | ------------------------------------------------------------- |
| `$DIYSHIP_SHELL` | Current shell name. |
| `$DIYSHIP_STATUS` | The status code of the previously run command. |
| `$DIYSHIP_PIPESTATUS` | Status codes from a command pipeline. |
| `$DIYSHIP_DURATION` | The execution duration of the last command (in milliseconds). |
| `$DIYSHIP_JOBS` | The number of currently running jobs |
| `$DIYSHIP_KEYMAP` | The current keymap. |

Do to many technical limitation, not every shell support all features:

| Feature | Bash | Zsh | Fish | Powershell | Ion | Elvish | Tcsh | Nushell | Xonsh |
| -------------------- | ---- | --- | ---- | ---------- | --- | ------ | ---- | ------- | ----- |
| Left prompt | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
| Right prompt | | โœ… | โœ… | | | โœ… | | | โœ… |
| Export current shell | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
| Export status | โœ… | โœ… | โœ… | โœ… | โœ… | | โœ… | | โœ… |
| Export pipe status | โœ… | โœ… | โœ… | | | | | | |
| Export duration | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… |
| Export jobs | โœ… | โœ… | โœ… | โœ… | โœ… | โœ… | | | โœ… |
| Export keymap | | โœ… | โœ… | | | | | | |

> _For more documentation and inspiration about writing your own prompt, checkout [ours wiki](https://github.com/info-mono/diyship/wiki) and [Starship's custom modules](https://github.com/starship/starship/discussions/1252)._

## ๐Ÿ’Œ Credits

This project was heavily based on and inspired by [**Starship**](https://starship.rs).





---

>

Made with โค๏ธ by @info-mono


>
>

Buy Me a Coffee