Skip to content

πŸ§°πŸš€ Cross-shell prompt CLI framework

License

Notifications You must be signed in to change notification settings

info-mono/diyship-classic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

34 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cross-shell prompt framework

License: GPL-3.0 Development completed

πŸ’‘ About

DIYship is a cross-shell prompt framework written in portable sh that let you write your prompt with any programing language for any shell.

Learn more about how its work.

πŸš€ Setup

🧾 Dependencies

  • sh to process.
  • date and cut for timing (required by Bash, Zsh, Elvish and Tcsh).
  • wc for job counting (required by Ion).
  • cat for return workaround (required by Xonsh).

πŸ“₯ Installation

πŸ”§ Manually

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

πŸ“¦ Package manager

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.

⌨️ Usage

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

🐚 Bash

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

eval "$(diyship bash)"

🐚 Zsh

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

eval "$(diyship zsh)"

🐚 Fish

Add the following to the end of ~/.config/fish/config.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.

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

🐚 Ion

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

eval $(diyship ion)

🐚 Elvish

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

eval (diyship elvish | slurp)

Only Elvish v0.15 or higher is supported.

🐚 Tcsh

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

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.

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:

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_<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.

πŸ’Œ Credits

This project was heavily based on and inspired by Starship.






Made with ❀️ by @info-mono

Buy Me a Coffee