Hacker News new | ask | show | jobs
by gremlinsinc 1500 days ago
you could create a bash function that echo's out the aliases, or perhaps feed it a keyword and it greps the commands and only gives you the ones you need.

something like:

    fgit(){
      fgcommands = "git commit...\n,git rebase...\n" 
      # you want one per line, so I'm not perfect at bash, w/out looking up how to do it I think you could cat it into the commands. 
      if [ -z $1 ]; then
        echo "$fgcommands"
        # returns all commands
      else
        echo "$fgcommands" | grep commit"
        # returns all commands with commit in. 
      fi
    }
You could even have more fun w/ it by creating some script that maybe remaps all your git commands so whenever you manually do git commit <flags> -- it'd run the command then also convert your command to a string, and run each word matching like commit, rebase, etc through fgit, and create some sort of "you could've done this instead"... I'd love if zsh had more things like that, but I only recently switched to zsh and oh-my-zsh is it so much better.

Think of this like in vscode when you use the command search, and it shows the keybindings next to it, so you can learn to do it better...