shrinker

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 14, 2019 License: MIT Imports: 5 Imported by: 0

README

Software License CircleCI Codecov branch Go Doc

path-shrinker

path-shrinker is a command to shrink directory path like this.

$ path-shrinker -short -last -tilde /Users/oinuma/go/src/github.com/oinume/path-shrinker
~/g/s/g/o/path-shrinker

Install

Download a binary

You can download a binary from GitHub.

Customize your Bash prompt with path-shrinker

Define PS1 in your .bashrc or .bash_profile.

PS1='$(path-shrinker -fish) $ '

Then your terminal will show a prompt like this:

~/g/s/g/o/path-shrinker $ pwd
/Users/kazuhiro/go/src/github.com/oinume/path-shrinker

Examples

For this directory tree:

/home/
  me/
    foo/
      bar/
        quux/
      biz/     # The prefix b is ambiguous between bar and biz.

Here are the results of calling path-shrinker <option> /home/me/foo/bar/quux:

Option        Result
<none>        /h/m/f/ba/q
-l|--last     /h/m/f/ba/quux
-s|--short    /h/m/f/b/q
-t|--tilde    ~/f/ba/q
-f|--fish     ~/f/b/quux

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmbiguousTransformer

type AmbiguousTransformer struct {
	StartDir    string
	ReadDirFunc ReadDirFunc
}

func (*AmbiguousTransformer) Transform

func (at *AmbiguousTransformer) Transform(input []string) ([]string, error)

type Config

type Config struct {
	PreserveLast bool
	Shorten      bool
	ReplaceTilde bool
	Mode         Mode
}

type Mode

type Mode int
const (
	ModeAmbiguous Mode = iota + 1
	ModeShort
)

type PreserveLastTransformer

type PreserveLastTransformer struct {
	Last string
}

func (*PreserveLastTransformer) Transform

func (plt *PreserveLastTransformer) Transform(input []string) ([]string, error)

type ReadDirFunc added in v0.1.1

type ReadDirFunc func(dirname string) ([]os.FileInfo, error)

type ReplaceTildeTransformer

type ReplaceTildeTransformer struct {
	HomeDir string
}

func (*ReplaceTildeTransformer) Transform

func (tt *ReplaceTildeTransformer) Transform(input []string) ([]string, error)

type ShortenTransformer

type ShortenTransformer struct{}

func (*ShortenTransformer) Transform

func (st *ShortenTransformer) Transform(input []string) ([]string, error)

type Transformer

type Transformer interface {
	Transform(input []string) ([]string, error)
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL