News for hackers. Stuff that matters.
Re:Bash Shortcuts For Maximum Productivity by arckiearc on Sunday September 11, 2011 @02:49AM (#2983366)
Great tips. !! is a nice timesaver when you've forgotten to prepend sudo to a command:

  $ /etc/init.d/rabbitmq-server restart
  Failed, need root access
  $ sudo !!
  Success
cd - is also quite cool, it takes you to the previous working directory.

  $ pwd
  /some/really/long/path/goes/here
  $ cd /var/log/app
  Work in this directory for a while, then go to previous dir
  $ cd -
  $ pwd
  /some/really/long/path/goes/here
Re:Bash Shortcuts For Maximum Productivity by gommm on Sunday September 11, 2011 @04:35AM (#2983482)
I have the following in my zshrc for sudo. It adds sudo at the beginning of the current line or writes sudo !! if the current line is empty. I've aliased it to alt+s

    run-with-sudo() {
      if [[ -z $LBUFFER ]]; then
        LBUFFER="sudo !!";
      else
        LBUFFER="sudo $LBUFFER";
      fi
    };
    zle -N run-with-sudo;
    bindkey '\es' run-with-sudo
Re:Bash Shortcuts For Maximum Productivity by arckiearc on Sunday September 11, 2011 @08:20AM (#2983668)
Nice little timesaver for such a common task, I'd just been doing the following (with vi editing on) but yours is much easier:

  esc-0-i-sudo
Re:Bash Shortcuts For Maximum Productivity by woogley on Sunday September 11, 2011 @08:57AM (#2983714)
It may not be less keystrokes, but for what it's worth, I find using shift+i is easier than 0-i
Re:Bash Shortcuts For Maximum Productivity by arckiearc on Sunday September 11, 2011 @07:36PM (#2985201)
Didn't know about that one, thanks!
Re:Bash Shortcuts For Maximum Productivity by joshu on Sunday September 11, 2011 @03:25AM (#2983410)
Don't forget pushd and popd.
Re:Bash Shortcuts For Maximum Productivity by graywh on Sunday September 11, 2011 @09:34AM (#2983759)
For Zsh, setopt autopushd