News for hackers. Stuff that matters.
Re:Ask HN: Best Command-Line Applications? by ivan_ah on Sunday November 18, 2018 @09:36PM (#18483824)
youtube_dl an ffmpeg would be my top two in terms of power.

Here are my top commands by frequency of use:

    4421 git
     952 open
     936 vim
     908 cd
     603 ls
     566 grep
     533 cp
     429 rm
     414 mv
     250 atom
     247 pip
     233 mkdir
     223 fab
     163 docker
     130 touch
     128 find
     123 youtube-dl
     113 python
     103 ssh
     100 cat
      99 wget
      81 pytest
      75 brew
total is of ~16k history lines... this means one in ever 4 commands I type is git! Wow I didn't know that. Probably `git status`...
Re:Ask HN: Best Command-Line Applications? by adtac on Sunday November 18, 2018 @09:50PM (#18483893)
I use git so much that I made these aliases in zsh:

    alias g="git show"
    alias gh="git show HEAD"
    alias gs="git status"
    alias gl="git log"
    alias gco="git checkout"
    alias gd="git diff"
    alias gbl="git branch -v"
    alias gbd="git branch -D"
    alias gri="git rebase --interactive"
    alias grc="git rebase --continue"
    alias gra="git rebase --abort"
    alias gst="git stash"
    alias gsta="git stash apply"
    alias gx="gco -- \*; git reset HEAD \*"
    alias gcp="git cherry-pick"
    alias gcpc="git cherry-pick --continue"
    alias gcpa="git cherry-pick --abort"
A few hundred instances of "gs" in my .zhistory :)
Re:Ask HN: Best Command-Line Applications? by lloeki on Monday November 19, 2018 @03:21AM (#18484865)
I find my git graph, git save, and git lint (also, git fetch --prune but lo alias for that one) extremely useful.

Aliases in my ~/.gitconfig:

    [alias]
        co = checkout
        cm = !git add -A && git commit
        br = branch
        ci = commit
        st = status
        unstage = reset HEAD --
        recent = for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"
        overview = log --all --oneline --no-merges
        recap = !git log --all --oneline --no-merges --author=${1-$(git config user.email)}
        today = !git log --all --since=00:00:00 --oneline --no-merges --author=${1-$(git config user.email)}
        changelog = !git log --oneline --no-merges ${1-$(git describe --abbrev=0)}..HEAD
        upstream = !git log --oneline --no-merges HEAD..${1-$(git branch -lvv | perl -ne '/^\\*.*\\[(.*?)\\]/ and print "$1\n"')}
        local = !git log --oneline --no-merges ${1-$(git branch -lvv | perl -ne '/^\\*.*\\[(.*?)\\]/ and print "$1\n"')}..HEAD
        graph = log --oneline --graph --all --decorate --date=iso
        save = !git add -A && git commit -m 'SAVEPOINT'
        undo = reset HEAD~1 --mixed
        backup = !git push origin/backup/$(whoami)/$(git branch)
        lint = !git branch --merged | grep -v \"^\\s*master$\" | grep -v \"\\*\" | xargs -n 1 git branch -d
Re:Ask HN: Best Command-Line Applications? by kippfe on Monday November 19, 2018 @07:41PM (#18490993)
Thanks for the tip.. :)
Re:Ask HN: Best Command-Line Applications? by codetrotter on Monday November 19, 2018 @07:17AM (#18485859)
I’ve been using short aliases for my most frequently used git commands for a few years now. I can’t imagine not using aliases.

  alias st='git status'
  alias dp='git diff'
  alias di='git diff --cached'
  alias aa='git add -A'
  alias cm='git commit -m'
  alias pu='git push'
Having these aliases of mine makes these actions something that you don’t need to spend any mental effort to perform at all.

I highly recommend others to define aliases that make sense to them for the most used got commands.

Mine are named the way they are because the two letter alias represents how I think of the action that the command performs:

* st - status

* dp - diff pending

* di - diff

* aa - add all

* cm - commit

If you define your aliases this way (speaking to the other readers of this thread, not the person I am replying to), you will find that the combinations become muscle memory quickly.

Notice also that unlike a lot of other people including the person I am replying to, my aliases are not prefixed with “g”. Again this boils down to your personal way of thinking. I’ve used other version control systems before, switched to git several years ago, and use git pretty much exclusively. I am of course aware at all times that I am working with git, but at the same time when I think of actions to perform, I don’t think of them as “git this or that”, I only think of the “this or that” part. If that makes sense :P

But yeah, find aliases that work and make sense for you.

Re:Ask HN: Best Command-Line Applications? by bhrgunatha on Monday November 19, 2018 @05:49AM (#18485476)
The oh-my-zsh git plugin [1] aliases have become second nature.

No need to install oh-my-zsh you can just take the file or cherry pick (!) the useful ones.

I may drop oh-my-zsh completely and just set up zsh with the small subset of plugins I use.

[1] https://github.com/robbyrussell/oh-my-zsh/tree/master/plugin...

Re:Ask HN: Best Command-Line Applications? by klatys on Monday November 19, 2018 @03:30AM (#18484892)
nice ones! couple from my bash_alias

    alias ..="cd .."
    alias ..2="cd ../.."
    # ... you get the idea, mine goes up to 5
    function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; }
    alias h="history|grep"
Re:Ask HN: Best Command-Line Applications? by bpmckenna on Monday November 19, 2018 @06:32AM (#18485653)
Instead of your `..` aliases, I have this, which saves some copy-pasting.

    function up() { cd "$(printf '../'%.0s $(seq 1 "${1:-1}"))" && pwd; } #up 4 goes up 4 directories
Re:Ask HN: Best Command-Line Applications? by sfdgsdfg on Tuesday November 20, 2018 @02:59AM (#18492443)

    alias ...="cd ../.."
    alias ....="cd ../../.."
Re:Ask HN: Best Command-Line Applications? by jakelazaroff on Monday November 19, 2018 @08:07AM (#18486109)
SCM Breeze has aliases like that, plus a bunch of other convenient things like numbered shortcuts for branches and files: https://github.com/scmbreeze/scm_breeze
Re:Ask HN: Best Command-Line Applications? by janlaureys on Monday November 19, 2018 @08:34AM (#18486266)
I use of few of these as well as alias stage="git add -A && git status" alias unstage="git reset HEAD && git status"
Re:Ask HN: Best Command-Line Applications? by ryannevius on Sunday November 18, 2018 @10:15PM (#18483988)
I find that...

    alias glol="git log --oneline"
...comes in handy as well, and it's fun to type.
Re:Ask HN: Best Command-Line Applications? by RichardCA on Monday November 19, 2018 @03:02AM (#18484807)
Try this one sometime...

  alias lg = log --date=format:'%Y-%m-%d %H:%M:%S' --pretty=format:'%cd %<(20,trunc)%an %C(auto)%h%Creset%C(auto)%d%Creset %s'
Re:Ask HN: Best Command-Line Applications? by brbrodude on Monday November 19, 2018 @07:09AM (#18485828)
hahah I have gs and gb(branch), just because I'm just constantly typing them(sometimes for no reason at all), others I end up typing the full commands tho
Re:Ask HN: Best Command-Line Applications? by andersonvom on Monday November 19, 2018 @10:42AM (#18487142)
gitsh - https://github.com/thoughtbot/gitsh

Since git is by far the command a lot of people type the most, this shell comes in really handy. It supports all regular git aliases, has autocompletion, and you can set default commands to be run when you just press return. It's amazing how much typing it saves.

Re:Ask HN: Best Command-Line Applications? by ufmace on Monday November 19, 2018 @02:06PM (#18488805)
+1 to Gitsh. Feels like it saves a massive amount of typing.