by dceddia · 6y ago · 0 comments
Yesterday I went looking for a similar key that would insert a copy of the last argument on the current line, like for when you want to copy or rename a file to a similar name in the same directory, as in `cp some/long/path/to/foo.txt some/long/path/to/foo2.txt`.
I couldn't find a command for this, so I made my own Zsh "widget" and bound it to Alt-/ so now I can type `cp some/long/path/to/foo.txt` and hit Alt-/ to prefill the second arg. I put the code for it up here: https://gist.github.com/dceddia/0a45a88dd61cbdf1be023d0a8f15...
function goto {
cd -P ~/.links/"$1";
}
And then in the `.links` folder I have symbolic links to directories I need to go to often.Then getting to a frequently used directory is just a `goto X` away.
This is more of a quick link to directories themselves.
Maybe you could do something similar to the alias if you had my `~/.links` directory in your CDPATH, but then you'd still need to add the `-P`every time to get it to follow the symbolic link.
Not something I had ever thought of before honestly.
`cp some/long/path/to/{foo,foo2}.txt`
(Though foo{,2}.txt is even shorter)
(I'm on a phone and normally rely on muscle memory so it might be the wrong symbols).
ls foo.txt !$
ls: ls: No such file or directory
foo.txtThere was one bash feature along the same lines of this. It was like bringing up the previous command in a shell script, so you could modify it freely, then run it. It was useful for long command, I think. Haven't tried learning it though. Just saw a couple wizard colleagues using it, and it seemed cool.