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

I recently setup something simple, but I've been falling in love with it - `goto`. Not as in the funny programming thing, with the even funnier `comefrom` variant in intercal, but as a simple shell script.

My issue is that at work, I tend to work with a lot of projects and repos, and I work a whole lot in a couple repos. And honestly, even if its short, typing `cd ~/Pro<tab>/an<tab>/main_<tab>` becomes old after 2000 times or more. And then there are ~80 - 90 repos in ~/Projects/terraform, and a couple dozen legacy repos in ~/Projects/chef, a dozen different config repos in ~/Projects/config, an automatically rotating scratchpad in ~/Stuff, ... I don't know if it's a messy workstation, or I'm just dealing with a boatload of stuff.

That's why I wrote goto. goto works in 2ish phases. The first phase just uses fzf -1 to give me a selection of the broad strokes I tend to navigate to. In case there is a prettier way to make fzf give me a static list of choices, let me know. It's basically:

    DESTINATION=$( echo "ansible\nterraform\nchef\nconfigs\n..." | fzf -1 "$1" )
This way I can either launch goto to get a list of 6-7 things I can select with arrows, by typing, or I can just be like `goto tf` and it directly selects `terraform`.

After that, it's a big switch-case selecting where to `cd` to, as well as possibly doing some normal init things. `ansible` as a destination for example just CDs and that's it.

`terraform` on the other hand does a bit more:

    case terraform)
        DESTINATION2=$( ls ~/Projects/terraform | fzf -1 "$2" )
        cd "$DESTINATION2"
        git pull --rebase
        # more stuff
    ;;
This way I can either say `goto`, select `terraform`, select a project and get moved there. Or I go `goto terraform` and type `prj2 foo` and usually fzf gives me the right thing, or I can be like `goto tf 'p2 fo'` and it drops me into the right place. Or something like `goto config infra-logaggregation` (or rather, `goto c ilg`). Or `goto stuff ticket-id` to get into some older scratchpad.

I'll just have to consider if I want to stick with ohmyzshs alias of g == git, which I don't really use much. Then I could achieve the entirely readable `g c ilg` to go where I need to, hah.

All of this is then wrapped into an alias, which basically aliases `goto` to be `source ~/goto`.

IDK, thanks for listening to my TED-talk on how to use fzf to juggle way too many hats at once. It's just saved me a lot of keystrokes getting around and mashing incomprehensible spells into the shell so coworkers are confused is always fun.



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

Search: