Cross-shell prompt framework
DIYship is a cross-shell prompt framework written in portable sh
that let you write your prompt with any programing language for any shell.
sh
to process.date
andcut
for timing (required by Bash, Zsh, Elvish and Tcsh).wc
for job counting (required by Ion).cat
for return workaround (required by Xonsh).
Option 1: using curl
curl https://raw.githubusercontent.com/info-mono/diyship-classic/main/bin/diyship > ~/.local/bin/diyship
chmod +x ~/.local/bin/diyship
Option 2: using git
git clone https://github.com/info-mono/diyship-classic.git ~/.local/share/diyship
ln -s ~/.local/share/diyship/bin/diyship ~/.local/bin/diyship
For Bpkg user:
bpkg install info-mono/diyship-classic
For Basher user:
basher install info-mono/diyship-classic
If you can and want to port DIYship to other package managers, feel free to do so.
Add the init script to your shell's config file:
Add the following to the end of ~/.bashrc
:
eval "$(diyship bash)"
Add the following to the end of ~/.zshrc
:
eval "$(diyship zsh)"
Add the following to the end of ~/.config/fish/config.fish
:
diyship fish | source
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
.
Invoke-Expression (@(&diyship powershell) -join "`n")
Add the following to the end of ~/.config/ion/initrc
:
eval $(diyship ion)
Add the following to the end of ~/.elvish/rc.elv
:
eval (diyship elvish | slurp)
Only Elvish v0.15 or higher is supported.
Add the following to the end of ~/.tcshrc
:
eval `diyship tcsh`
Add the following to your Nushell config file. You can check the location of this file by running config path
in Nushell.
startup = [
"mkdir ~/.cache/diyship",
"diyship nushell | save ~/.cache/diyship/init.nu",
"source ~/.cache/diyship/init.nu"
]
prompt = "diyship_prompt"
Add the following to the end of ~/.xonshrc
:
execx($(diyship xonsh))
Only Nushell version v0.33 or higher is supported.
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_<POSITION>="<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 and Starship's custom modules.
This project was heavily based on and inspired by Starship.
Made with β€οΈ by
@info-mono