GithubHelp home page GithubHelp logo

sudo's Introduction

sudo

This is an intresting plugin from oh-my-zsh,
⚠️ please note that all credits are of oh-my-zsh team


This seeams doesn't work in combination with zap-zsh/vim, althogh it works with standard ZSH VI mode (bindkey -v)

Easily prefix your current or previous commands with sudo by pressing esc twice.

Usage

To use it, add "zap-zsh/sudo" to the plugins in your zshrc file:

plug "zap-zsh/sudo"

Current typed commands

Say you have typed a long command and forgot to add sudo in front:

$ apt-get install build-essential

By pressing the esc key twice, you will have the same command with sudo prefixed without typing:

$ sudo apt-get install build-essential

The same happens for editing files with your default editor (defined in $SUDO_EDITOR, $VISUAL or $EDITOR, in that order):

If the editor defined were vim:

$ vim /etc/hosts

By pressing the esc key twice, you will have the same command with sudo -e instead of the editor, that would open that editor with root privileges:

$ sudo -e /etc/hosts

Previous executed commands

Say you want to delete a system file and denied:

$ rm some-system-file.txt
-su: some-system-file.txt: Permission denied
$

By pressing the esc key twice, you will have the same command with sudo prefixed without typing:

$ rm some-system-file.txt
-su: some-system-file.txt: Permission denied
$ sudo rm some-system-file.txt
Password:
$

The same happens for file editing, as told before.

Key binding

By default, the sudo plugin uses EscEsc as the trigger. If you want to change it, you can use the bindkey command to bind it to a different key:

bindkey -M emacs '<seq>' sudo-command-line
bindkey -M vicmd '<seq>' sudo-command-line
bindkey -M viins '<seq>' sudo-command-line

where <seq> is the sequence you want to use. You can find the keyboard sequence by running cat and pressing the keyboard combination you want to use.

sudo's People

Contributors

mamaraddio avatar

Stargazers

Illia Roman avatar WP avatar Daniel Rivas avatar Briain O'Driscoll avatar  avatar ヤコブ avatar Rishabh avatar Wuelner Martínez avatar

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.