prezto
prezto copied to clipboard
Hope there would be "sudo" and "wd" plugins
It's very useful when I use oh-my-zsh
What do these actually do? It looks like wd is another dir jumping plugin (we already have z and fasd, so I doubt we'd add another... and we're also looking at removing fasd)... and I'm not familiar with what the sudo module does... it looks like it adds an additional keybind, but I'm not sure what it's used for.
The sudo plugin is used to fix earlier commands whose the user forgot to wrote sudo before. The usage: press ESC twice and return the last command with a prefixed sudo
.
Example:
> vim /etc/fstab
... [sucks, need sudo]
> # Press ESC twice
> sudo vim /etc/fstab
I hope at least the sudo
plugin would be added, indeed is a very useful plugin on oh-my-zsh
.
The implementation on oh-my-zsh
of sudo
or sudoedit
plugin can be found here.
With the example you gave I usually do something like this:
> vim /etc/fstab
... [sucks, need sudo]
> sudo !!
... [expands to sudo vim /etc/fstab]
The zsh man pages explain it under History Expansion:
!! Refer to the previous command. By itself, this expansion repeats the previous command.
I'm not rejecting this request because it does seem useful, perhaps as an option in another module. However, it's not a high priority for me to implement because there's something built in which only takes 4 additional key strokes.
I understand the priority is not high. But if I implement a port from oh-my-zsh
and submit a pull request this can be accepted? After all, I just download the module here and did a source sudo.plugin.zsh
and works somehow (a little slow em comparison to the oh-my-zsh, but works).
I think it would make more sense as something like the editor
module (we're trying to avoid having hundreds of plugins like oh-my-zsh - I'd rather have a smaller number of larger, configurable plugins) but then it would need some changes so it makes sense with both emacs and vi bindings.
Unless anyone else disagrees I would accept a PR which added it to a module where it makes sense and handles both emacs and vi key binds (esc-esc in vi mode would be weird).
Personally I think sudo !!
is fine, and not worth adding this.
sudo
plugin does one more cool thing - when you are typing command and you realize you forgot sudo in the beginning, you can hit Esc
twice and sudo will be added in the beginning without moving the cursor. You can continue typing immediately.
Double Esc
is just so much faster than Home
button, sudo, End
button or any keybindings to move cursor to beginning and back to the end. It's also much faster than mentioned sudo !!
.
Overall I believe it is useful.
Workaround I'm using for now - paste contents of sudo plugin zsh file into ~/.zshrc
file and reopen your terminal.
I use zsh-dwim, which provides a keybinding of C-u
and does contextual completions, it's easy enough to drop it in .zsh-contrib
. There are other tools like thefuck which provide similar features for a larger set of applications.
For me, adding such a feature is a gateway to allowing more context based completions which are already handled well by the above listed plugins. It's probably better to delegate to them rather than re-invent the wheel in this particular case.
A rogue mouse closed the issue :disappointed_relieved:
wd
vs z
wd
lets you create custom names for directories.
- So for example, you can do
-
wd add fcore
- and then type
-
wd fcore
to go to that current directory
-
whereas you need to start typing the actual directory name
z frontend-core
I was able to install wd
manually from their README instructions