Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm a zsh user, but here's a couple of things I find pretty invaluable:-

    bindkey '^Q' push-line
The 'push-line' widget allows you to quickly type another command and will restore the previous one once you've entered it.

    # re-run the previous command with sudo
    rerun-with-sudo () {
      LBUFFER="sudo !!"
      zle accept-line
    }
    zle -N rerun-with-sudo
    bindkey '^Xx' rerun-with-sudo
Re-run the previous command prefixed with sudo by typing ^X then x.

And:-

    # build git clone command from clipboard
    git-clone-clipboard() {
        REPO_URL="$($CLIPBOARD)"
        REPO_BASE_NAME=${$(basename $REPO_URL)%.git}
        LBUFFER="nocorrect git clone $REPO_URL $REPO_BASE_NAME"
    }
    zle -N git-clone-clipboard
    bindkey "^Xg" git-clone-clipboard
^Xg prefixes a git url with "git clone" and fills out the command line.

Couple similar things for wget, youtube-dl here: https://github.com/gaving/dotfiles/blob/master/.zsh/config



I'm also a big zsh user, one of the biggest timesavers for me was to get autocompletion of the arguments from the last command working. I use meta-. for the last argument, but !:# syntax is awkward and I don't often remember exactly what number parameter something was. Took a bit of screwing around, but I eventually figured it out and the details are on the unix/linux stack exchange site: http://unix.stackexchange.com/questions/5229/add-arguments-f...


If I have a URL in my clipboard and want to prefix it I use:

    git clone `xclip -o`
Much simpler and no customization needed.


uh, why wouldn't you just actually paste the url into your terminal at that point instead of typing `xclip -o`?

and yeah, typing the actual command into the terminal is always going to be 'simpler'




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: