winget install --id=donmar.bonsai -e
A cli tool for navigation and execution
Bonsai is a CLI tool designed to enhance navigation and execution within command-line environments, featuring an Explorer-like UI for intuitive file management. It allows users to quickly access directories and execute files with ease. Key features include themeable UIs, customization of themes and key bindings, integration with shells like PowerShell, support for regex search, and the ability to track used directories and files in a database.
Ideal for developers, system administrators, and power users, Bonsai boosts productivity by streamlining navigation and file execution. Its customizable interface adapts to individual workflows, enhancing efficiency. Installation is straightforward via winget: winget install donmar.bonsai
.
A simple cli tool that provides a better 'change directory' and file execution experience.
Also a user interface for explorer like navigation is included (themeable).
Currently only tested on Windows with PowerShell and Windows Terminal.
Install binary
The recommended way to install bonsai is via winget.
winget install donmar.bonsai
Setup your shell
Add this to your powershell profile (Run echo $profile
in PowerShell to locate it.):
Invoke-Expression (& { (bonsai init powershell | Out-String) })
This will execute the contents of init.ps1
Note: For already running powershell sessions you have to reload your profile after modifying it. You can do this by executing this
. $PROFILE
Asume that we have this directory structure and our working directory is C:
C:
├─tempor
│ ├─consetetur
│ │ └─sadipscing
│ │ elitr.txt
│ │ amet.ps1
│ │
│ ├─nonumy
│ └─lorem
│ └─ipsum
│ │ amet.ps1
│ │
│ ├─dolor
│ └─nonumy
├-invidunt
└-ipsum
b # Opens the explorer app at the current working directory
b tempor/consetetur # Changes directory to "C:\tempor\consetetur"
# because tempor/consetetur is a subdirectory of C:\
# We assume that bonsai have already been used and the database
b nonumy # will open an UI aksing which of the two nonumy folders you ment
b tem sum # will change directory to "C:\tempor\lorem\ipsum"
b scing amet.ps1 # will execute "C:\tempor\consetetur\sadipscing\amet.ps1"
Everytime you use bonsai to navigate or execute a file this will be stored in the database.
Key bindings can be modified in settings.json
Key | Action |
---|---|
Esc | Close |
UpArrow | select previous item in list |
DownArrow | select next item in list |
PageUp | select item one page up in list |
PageDown | select item one page down in list |
ctrl+Home | select first item in list |
ctrl+End | select last item in list |
Key | Action |
---|---|
Enter | open directory in explor |
ctrl+Enter | Select directory/File and exit explorer |
ctrl+I | Load sub directories and files from sub directory (! This could take a bit) |
ctrl+R | toggle regex search |
alt+UpArror | open parent directory |
Key | Action |
---|---|
Enter | Select directory/File and exit |
The configuration is stored in
Windows: %userprofile%\.bonsai
Contents of the folder are:
Property | Values | Description |
---|---|---|
showParentDirectoryInList | true/false | true to shwo the parent directory in explorer as ".." |
theme | e.g default.json, justicons.json | The theme file to use which has to be located in the themes folder |
maxEntryAgeInDays | integer | The amount of days after which an entry in the database should be removed. |
maxIndividualScore | integer | The max score an entry should be able to get. If any entry exceeds this value, scores of all entries will be reduced and all falling below 1 are getting deleted. |
keyBindings | Key: KeyBindingContext, Value: List<KeyBinding> | The keybindings to use |
fileCommands | List<FileCommand> | commands that should be used when selecting files. When not set, the shell decides what to do with file |
directoryCommands | List<DirectoryCommand> | commands that should be used when selecting directories. When not set change directory to will be executed If you add a directoryCommand you might want to register also the the change directory command for powershell: {"action": "Set-Location \"[path]\"", "displayName": "Change directory"} |
Common,
ExplorerApp,
NavigationApp
Property | Description |
---|---|
extension | the extension (include the . e.g ".ps1") for which the command should be available. "*" = all files |
action | the expression which should be executed =="[path]"== will be replaced with the full qualified name of the file. eg: "code "[path]"" will open Visual Studio Code with the given file |
displayName | the name which should be displayed if more than one command is available |
Property | Description |
---|---|
action | the expression which should be executed =="[path]"== will be replaced with the full qualified name of the directory. eg: "ii "[path]"" will open the windows explorer |
displayName | the name which should be displayed if more than one command is available |
Property | Values | Description |
---|---|---|
modifier | ConsoleModifiers | Use "None" if no modifier should be used |
key | ConsoleKeys | Either key or keyChar have to be given (both is fine to) |
keyChar | char representing the key | Either key or keyChar have to be given (both is fine to) |
action | NoneExitOpenDirectory OpenParentDirectory ConfirmSelectionListSelectPreviousItem ListSelectNextItem ListSelectOnePageUp ListSelectOnePageDown ListSelectFirstItem ListSelectLastItem ToggleShowDetailsPanel ToggleIncludeSubDirectories ToggleRegexSearch |
This is the script which will be executed when bonsai init [shell]
is executed.
db.json