Code Monkey home page Code Monkey logo

Comments (19)

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

alias _='sudo' is defined in alias.zsh. Why don't you use that?

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

I don't think that I have a free and meaningful key for binding this. I will not break C-s. I could change _ to s, and you could type C-a, s, SPACE. That's two more keys unfortunately. You don't need sudo that often, do you?

from prezto.

gwjo avatar gwjo commented on May 22, 2024

Clobbering C-a is a bad idea, since it's the default prefix for screen commands.

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

@gwjo I'm not clobbering C-a. That's the default key binding for moving the cursor to the beginning of the line in the Emacs layout. I'm telling @giddie to go to the begging of the line, type s, then spacebar, then hit enter. How GNU Screen users deal with Emacs layouts is not my concern.

from prezto.

giddie avatar giddie commented on May 22, 2024

To be clear: this isn't a quick way of typing "sudo" (although that does work); this prepends "sudo" to the current line. For instance, I'm halfway through typing a command when I realise I need to be root to do it, so I press C-s, and "sudo" is added to the start of the line. That way, I don't have to throw away the line and retype it.

I administer several ArchLinux servers at work and one at home. I need "sudo" pretty frequently. Maybe that's unusual, though.

BTW, can't I scroll through history search using arrow keys?

Anyway, I'm happy with this in my fork, but it took me a while to figure out how to do this, and I wonder how many other people might benefit from stumbling upon this code in OMZ and thinking "Huh, that's a neat idea".

from prezto.

giddie avatar giddie commented on May 22, 2024

@sorin-ionescu Ah; I see. Yeah, I could use C-a and C-e to achieve the same thing; I didn't honestly know about those bindings. That takes more keystrokes, though. I like my binding :) If you think it's not going to be useful to anyone else, I understand.

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

Typing C-a, s, space, C-e is certainly more work than C-s. But, I still can't see where I can bind it. You can execute bindkey -L to see the current bindings.

from prezto.

giddie avatar giddie commented on May 22, 2024

Do you know where C-r and C-s came from for history-incremental-pattern-search? I'm considering switching them with C-n and C-p (history-substring-search), which are already bound to the up and down keys. That would free up my C-s (and maybe I could use C-r for my push-line-or-edit binding).

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

@giddie They come from Emacs, but all bindings are found in keyboard.zsh.

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

I can bind this to C-X C-S in emacs mode. TBD in Vi mode.

from prezto.

giddie avatar giddie commented on May 22, 2024

I've chosen Escape-S in Vi mode. How does that sound to you?

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

It's probably going to be C-X C-S for both. It's easier to type than ESC-S or C-[ C-S.

from prezto.

giddie avatar giddie commented on May 22, 2024

Agreed. C-x is also self-insert in vi-mode. The idea of having "special" bindings like this tidied under C-x appeals to me. It gives me scope to add more if I want.

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

There are quite a few C-X bindings. Don't go trigger happy now. Check before you bind.

from prezto.

giddie avatar giddie commented on May 22, 2024

I'm not seeing any bindings under C-x in vi-mode, which is all I really care about when it comes to my own use. If I were to suggest a new binding for general consumption, I'd be sure to check Emacs-mode doesn't already have that key bound :)

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

There is a problem with this implementation. It's too dumb. It prepends sudo at the beginning of the line when it should prepend at the beginning of the current command in order to work in multi-command lines or multi-line commands.

from prezto.

giddie avatar giddie commented on May 22, 2024

True; this is OK for my needs, though Thanks for including this :)

from prezto.

sorin-ionescu avatar sorin-ionescu commented on May 22, 2024

I don't include anything for one man's needs. It has to be useful to many. That said, making this command aware will be a pain. It's probably not worth it.

from prezto.

giddie avatar giddie commented on May 22, 2024

Absolutely, I would hope not!

from prezto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.