News for hackers. Stuff that matters.
Re:Ask HN: Which tools have made you a much better programmer? by tych0 on Tuesday June 09, 2020 @02:46PM (#23469453)
My life was also improved with some additional aliases in my git config:

[alias] dfif = diff idff = diff grpe = grep

Re:Ask HN: Which tools have made you a much better programmer? by jaeckel on Tuesday June 09, 2020 @05:43PM (#23471242)
I'm always puzzled how often the wheel gets re-invented ... https://git-scm.com/docs/git-config#Documentation/git-config...
Re:Ask HN: Which tools have made you a much better programmer? by Kaze404 on Tuesday June 09, 2020 @07:21PM (#23472074)
This is only for git commands though? `diff` and `grep` are their own thing.
Re:Ask HN: Which tools have made you a much better programmer? by OJFord on Tuesday June 09, 2020 @08:01PM (#23472397)
Not when they're git subcommands, or misspelt git aliases as above.
Re:Ask HN: Which tools have made you a much better programmer? by inetsee on Tuesday June 09, 2020 @03:26PM (#23469903)
Years ago Interlisp (does anybody here remember Interlisp?) had a function called DWIM (AKA Do What I Mean). It was an (optionally enabled) part of the REPL. If you typed something that made no sense, DWIM would try to figure out what you really meant to type, and offered to run the corrected command.

I have often wondered why that functionality disappeared, and why no one has tried to resurrect it. Search engines offer corrections all the time; why doesn't bash?

Re:Ask HN: Which tools have made you a much better programmer? by bitwize on Tuesday June 09, 2020 @03:53PM (#23470180)
Quaxity quuxity,

Teitelman's Interlisp

Has a DWIM feature that's

Really a screw;

MACLISP has evident

Superiority

Letting its customer

Mean what he do.

--The Great Quux (Guy L. Steele)

This poem indicates the frustrations that hackers had with DWIM at the time, which may explain why no one tried to resurrect it. Too-clever-by-half features intended to help tend to drive people nuts, especially when they fail. Even when they succeed, they interrupt the user's flow and become like that dialog box Windows users just dismiss.

Re:Ask HN: Which tools have made you a much better programmer? by reificator on Tuesday June 09, 2020 @08:30PM (#23472584)
Re:Ask HN: Which tools have made you a much better programmer? by abhiyerra on Tuesday June 09, 2020 @03:36PM (#23470006)
Zsh has this. But it mostly drives me mad.
Re:Ask HN: Which tools have made you a much better programmer? by smichel17 on Tuesday June 09, 2020 @02:57PM (#23469574)
bashrc snippet (with extra newlines, for folks on mobile apps like materialistic that don't understand code formatting):

    # I do this an embarrassing amount

    alias fgf='fg'

    alias fgfg='fg'

    alias gf='fg'

    alias gfg='fg'
Re:Ask HN: Which tools have made you a much better programmer? by twright0 on Tuesday June 09, 2020 @10:04PM (#23473125)
This resonates... from mine:

  alias emcas='emacs'

  alias emac='emacs'

  alias emasc='emacs'

  alias enacs='emacs'

  alias emas='emacs'

  alias emascs='emacs'

  alias eamcs='emacs'

  alias eemacs='emacs'
Re:Ask HN: Which tools have made you a much better programmer? by Jtsummers on Wednesday June 10, 2020 @04:56PM (#23482019)
I have aliased `emacs --daemon` to `emacsd` and `emacsclient -t` to `e` because I use it so much.
Re:Ask HN: Which tools have made you a much better programmer? by andrethegiant on Tuesday June 09, 2020 @03:43PM (#23470079)
You might be interested in https://github.com/nvbn/thefuck
Re:Ask HN: Which tools have made you a much better programmer? by ufo on Tuesday June 09, 2020 @04:21PM (#23470463)
In a similar theme, I'm really glad I added ":q" as an alias for "exit" in my shell.
Re:Ask HN: Which tools have made you a much better programmer? by karatestomp on Tuesday June 09, 2020 @05:17PM (#23471014)
I must forget to give grep an filesystem path argument at least 10% of the time I invoke it. What I'm intending to do in all of those cases is recursively grep in the current directory. "Warning: recursive search of stdin" might be my most-seen console error message.
Re:Ask HN: Which tools have made you a much better programmer? by 0xADEADBEE on Tuesday June 09, 2020 @05:41PM (#23471221)
This used to happen to me constantly. I fixed it accidentally in switching to Ripgrep [0] which defaults to recursively searching the current directory. Bonus: it parallelises too!

Honourable mention also to FZF [1] which not only makes it trivial to locate a file in a directory tree, but has revolutionised my history use with its fuzzy matching.

[0] - https://github.com/BurntSushi/ripgrep

[1] - https://github.com/junegunn/fzf

Re:Ask HN: Which tools have made you a much better programmer? by adamredwoods on Tuesday June 09, 2020 @03:27PM (#23469914)
Nice! I create two-letter aliases, it truly helps:

gc = git checkout

gs = git status

etc...

Re:Ask HN: Which tools have made you a much better programmer? by elwell on Tuesday June 09, 2020 @03:48PM (#23470132)
Here's mine:

    alias g="git"
    __git_complete g _git # enable git autocompletion (braches, etc.)
    alias gc="git commit -am"
    alias gp="git push"
    __git_complete gp _git_checkout # checkout is more useful than _git_push because it autocompletes the branch
    alias ga="git add -A"
    alias gd="git diff"
    alias gb="git branch"
    alias gx="git checkout"
    __git_complete gx _git_checkout
    alias gs="git status"
    alias gl="git log"
Re:Ask HN: Which tools have made you a much better programmer? by thinkmassive on Tuesday June 09, 2020 @04:24PM (#23470499)
Good collection! I have many of these, plus a slightly longer one for quick fixups that happen all too often:

    alias gcane="git commit --amend --no-edit"
Re:Ask HN: Which tools have made you a much better programmer? by jaeckel on Tuesday June 09, 2020 @05:45PM (#23471277)
probably you will like

  function fixup() {
    git commit --fixup=$1
  }
  function refixup() {
    git rebase -i --autosquash --autostash $1^1
  }
Re:Ask HN: Which tools have made you a much better programmer? by ArtDev on Tuesday June 09, 2020 @06:20PM (#23471597)
I have a ton of aliases but I have them all proceeded by an underscore. That way, I don't muck up native commands.

alias _up='sudo apt update -y && sudo apt upgrade -y'

Re:Ask HN: Which tools have made you a much better programmer? by tejohnso on Tuesday June 09, 2020 @04:05PM (#23470285)
Nice, I have those same aliases.

Also not afraid to add multi-letter aliases if I find myself typing the same multi-word command over and over.

For example git diff master HEAD becomes gdmh

Re:Ask HN: Which tools have made you a much better programmer? by djmetzle on Tuesday June 09, 2020 @09:33PM (#23472916)
alias g=git

And then define one and two letter aliases for the things you do often:

st=status

l=log --with-prettiness

ap=add --patch

shit=reset

co=checkout

Re:Ask HN: Which tools have made you a much better programmer? by vfinn on Tuesday June 09, 2020 @11:05PM (#23473484)
heh, I should make an alias for no-break space (code point 160/00A0) + 'grep', because I type it so often when I pipe and get:

Command ' grep' not found, but there are 17 similar ones. Maybe I'm not the only one :).

Re:Ask HN: Which tools have made you a much better programmer? by seqizz on Tuesday June 09, 2020 @02:51PM (#23469502)
I handle this case with auto-correction for all one off errors via <tab>.