I'm looking for a command that invokes readline or similar, primed with the current $PWD, to let the user edit the current directory, then cd to the edited value. E.g.
> cd ~/a/b/c/d
> pwd
> /home/alice/a/b/c/d
Then run the proposed icd command (for "interactive cd", inspired by
imv in renameutils). It prompts the user as follows:
> icd
icd> /home/alice/a/b/c/d
Then the user can, e.g. press Alt-b, Alt-b, Alt-t, resulting in:
icd> /home/alice/a/c/b/d
(Alt-t transposing b and c)
Upon pressing Enter, the icd command changes the current directory to /home/alice/a/c/b/d.
Ideally icd would have some autocompletion. Maybe even visual indication of whether the current value is an existing/valid directory.
This can nearly be done in zsh by typing
> cd `pwd`
then pressing Tab. But a command like icd would save keystrokes.
Related: Interactive cd (directory browser)
sh, making the answer more generally helpful, while also still probably compatible withzsh. I named a shell at all because, e.g. acsh-specific answer would not help me. – Robert Fleming Jul 12 '19 at 16:28