git-worktree-switcher
git-worktree-switcher copied to clipboard
Avoid creating a new shell instance when using wt
This PR creates shell functions that invoke wt and cd into the given directory. This partially solves #11.
What changed:
- When running
wtand giving it a valid worktree name, itecho's outchangedir:<path>. - Adds the
initsub-command for generating the shell code of the function. - The installation now requires the addition of a line to the shell config that invokes wt and runs the generated code. This is reflected in the readme.
I believe some further changes would be nice, but might be outside the scope of this PR:
- Add a
--prefix for the sub-commands, to avoid collisions with worktree names. - The new
initoperation could also generate the completion scripts to reduce installation complexity. (This could be implemented in this PR) - Shell completions could include the sub-commands.
Some notes:
- This introduces breaking changes, because the installation changed.
- Instead of the shell function invoking
wt, the whole script could be inside the shell function, thus not needing the ugly echoing. - The error messages are not the best...
- Maybe the whole thing should be refactored :)