xen0n / autojump-rs

A fast drop-in replacement of autojump written in Rust
https://github.com/xen0n/autojump-rs/releases
GNU General Public License v3.0
243 stars 14 forks source link

Question: Should <dir> in "autojump --add <dir>" be an absolute path? #45

Open maxild opened 3 years ago

maxild commented 3 years ago

I was looking for something cross-plat (windows, macos, linux) that could work in bash, zsh and windows-powershell.

I had to write the j script myself in powershell (because j.bat only works in CMD). I had to hook into cd (set-location), pushd (Push-Location) and popd (Pop-Location), such that the tool could learn how I navigate the filesystem. I have chosen to convert any new location to an absolute path before calling --add sub-command, in order for .., ../.. and other relative paths to have universal meaning (at least at my windows pc).

I wanted to avoid someting like this (because relative paths would loose all meaning in the dynamic config because the tool doesn't know relative to what folder!)

10.0:   .\Projects\config\dotfiles-powershell\
14.1:   .\Projects\
14.1:   ..
17.3:   C:\Users\maxfire\Projects\

Is this how it should be done?

xen0n commented 3 years ago

Hi, short answer is "yes".

According to upstream autojump's hook scripts, for example the one for zsh, you can see it uses pwd to get the current directory, which is always absolute. The reason you described is valid.

leumasme commented 1 year ago

I had to write the j script myself in powershell (because j.bat only works in CMD).

Aha, i knew i was missing something - i just installed it via scoop and was severely confused and left only with a single autojump.exe binary. So from what I understand, unless you want to manually add each entry to the index via --add or write/find your own powershell integration, the extras/autojump package on scoop (Added in https://github.com/ScoopInstaller/Extras/pull/8377) is currently not usable. As I believe powershell has mostly superseded cmd for manual shell use, a powershell integration is pretty essential for windows support. Perhaps @maxild could share theirs? The commands (such as cd) could then be hooked by just running the hook command/script inside the Powershell $PROFILE file. (See similar: Installation flow for starship) Additionally, the scoop package manifest should be updated to also download the powershell integration, or it should be included in the windows downloads during the CI build