Skip to content

Latest commit

 

History

History
190 lines (127 loc) · 6.96 KB

README.md

File metadata and controls

190 lines (127 loc) · 6.96 KB

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