Giter Club home page Giter Club logo

goat's Introduction

goat

Overview

I used to retrieve carefully-constructed cd commands from my history. But then, I got a goat.

~ Jonathan Paugh on Google+

[ ~/Pictures ] $ goat dev ~/Documents/devel # create a link to the dev directory
[ ~/Pictures ] $ ls # see that there is no ~/Pictures/dev directory here
seahorses wallpapers
[ ~/Pictures ] $ cd dev # the goat framework's got you covered!
[ ~/Documents/devel ] $

Oh my! This is a POSIX-compliant shell movement boosting hack for real ninjas.
#posix_me_harder #posixly_correct

~ 0mp

Sometimes you jump around your filesystem tree a lot and you end up putting a couple of ugly aliases into your shell's rc file.

I should try it, even if it is dumb!

~ dse on What the Daily WTF? about goat v1.1.1

With goat you can easily manage your ninja shortcuts - just type goat p ~/Projects to introduce a new link and then cd p to jump to its destination.

Rad! I can do cd .... now instead of performing a horse galloping-like waltz with ../ being my miserable dance floor. I'm cloning this goat straight away!

~ YA0mp

BTW, Bash completion is now fully working with goat's shortcuts.

Building

$ make all

Installation

$ make install

Aferwards:

  • Make sure that ~/.local/bin is in your PATH:

    $ cat <<'EOF' >> ~/.bashrc
    case "$PATH" in
        *$HOME/.local/bin*) ;;
        *) PATH="$HOME/.local/bin:$PATH" ;;
    esac
    EOF
  • Make sure that files inside ~/.local/etc/bash_completion.d are actually sourced by the Bash completion library:

    $ cat <<'EOF' >> ~/.bash_completion
    if [[ -d ~/.bash_completion.d ]]
    then
        for f in ~/.local/etc/bash_completion.d/*
        do
            [[ -f $f ]] && source "$f"
        done
    fi
    EOF

Usage overview

Create a shortcut named “f” to ~/Documents/dev/freebsd (no need to use
the link command explicitly here):

      $ goat f ~/Documents/dev/freebsd

Follow a link to change a directory with cd(1):

      $ cd f

Take the “f” shortcut and enter its destination subdirectory with just
one command:

      $ pwd
      /home/0mp
      $ cd f/ports
      $ pwd
      /usr/home/0mp/freebsd/ports

Create a shortcut named “p” to the current directory:

      $ goat p .

Go up the filesystem tree with ... (same as the standard “cd ../../”):

      $ cd ...

List all your links:

      $ goat list
      dots    ->      /usr/home/0mp/.dotfiles
      down    ->      /usr/home/0mp/Downloads
      f       ->      /usr/home/0mp/freebsd
      p       ->      /usr/home/0mp/freebsd/ports
      pa      ->      /usr/home/0mp/freebsd/patches
      src     ->      /usr/home/0mp/freebsd/svn/src
      svn     ->      /usr/home/0mp/freebsd/svn

Delete a link (or more):

      $ goat delete f p

Delete all the links which point to directories with the given prefix:

      $ goat deleteprefix "$HOME/Documents"

License

Licensed under 2-Clause BSD license. Copyright © 2016-2021 Mateusz Piotrowski

goat's People

Contributors

0mp avatar falkendk avatar garyleutheuser avatar kfbi1706 avatar khamer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

goat's Issues

Installation instructions may fail

The following (from readme)

./goatherd target install

fails and outputs

cp: cannot stat ‘./target/goat.sh’: No such file or directory

I'm using debian 8

Fix goat w .

When I call goat w . on macOS in bash I get:

sed: 1: "7
22
31d
": command expected

This must be a sed-realted bug.

The shortcut can be still configure by adding it manually to the file with shortcuts.

Add tests

  • Are there any CI services for shell scripts?
  • Write tests for goat.sh.
  • Is there any tool which checks for bashisms?

Test get_entry

I am not sure if $numer_of_lines equalas 0 if there are no lines grepped.

Improve the goat's presence in bashrc

Instead of adding

alias goat=". /Users/user/.goat/goat-agent.sh"

cd_extended_wth_goat() {
    [ "$1" = "" ] && command cd
    command cd "$1" 2>/dev/null ||  . /Users/user/.goat/goat-agent.sh "$1"
}

alias cd="cd_extended_wth_goat"

to the .bashrc file it would be smarter to add

.  /Users/user/.goat/shell.config

to .bashrc and

alias goat=". /Users/user/.goat/goat-agent.sh"

cd_extended_wth_goat() {
    [ "$1" = "" ] && command cd
    command cd "$1" 2>/dev/null ||  . /Users/user/.goat/goat-agent.sh "$1"
}

alias cd="cd_extended_wth_goat"

to . /Users/user/.goat/shell.config.

Deinstall goat

It would be nice to have a script removing goat from .bashrc.

The solution which comes to my mind is:

  1. Delete goat from .bashrc during a dry run.
  2. Show the user a diff of what is going to be deleted.
  3. Prompt the user to accept the changes and delete goat from the rc file.

Related: #14

Add relative paths

It would be cool to manage aliases like cd ... -> cd ../.. with goat.

At the moment goat always saves the absolute path when adding a shortcut with the standard goat shortcut ..

How about goat please add relative ... ../..

Make cd ..... easy

Let goat detect cd ... and resolve it to cd ../... Make it work for any number of dots.

Handle the `cd -` properly

At the moment when you run cd - goat will take you to the previous directory and print the path onto the terminal.

Rewrite goat-keeper.sh

I thought that it might be a good idea to use make instead of the goat-keeper.sh script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.