superfile
superfile copied to clipboard
Improve cd_on_quit
The part you want to Enhancement
I want to improve the newly introduced cd_on_quit feature.
Currently, the cd_on_quit features requires bash users to copy/paste some code into their .bashrc
. This code is arguably a bit large and will probably never be updated.
I propose that we take some inspiration from zoxide. Zoxide has a init
command that prints the correct cd_on_quit
code for a passed shell. If sbf would also have such an init command, running sbf init bash
would give us the code that we'd have to copy/paste into .bashrc
.
This is arguably only a small improvement, but we can do even better!
We can call sbf init bash
inside the .bashrc
file and directly evaluate the returned code.
In practice, we'd have to insert the following line in our bashrc
:
eval "$(sbf init bash)"
Equvivalently, for powershell we'd have to add the following code to $PROFILE
:
Invoke-Expression (& { (zoxide init powershell | Out-String) })
Why it is necessary to enhancement
This gives us the following advantages:
- Setting up cd_on_quit gets slightly easier
- We can update the cd_on_quit script with each update
- We can even create custom cd_on_quit scripts.
- We could e.g. dynamically set the sbf file paths in the Powershell script.
- This would mean that the location of
sbf.exe
would no longer be hard-coded. - This would ease integration in windows package managers such as scoop