Skip to content

Commit

Permalink
Add -y option
Browse files Browse the repository at this point in the history
  • Loading branch information
bayashi committed Mar 20, 2024
1 parent e4c35a8 commit 1cedd4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
$ pwd | highlightrepo
```

Use `-y` option for `PS1`

```sh
PS1="[\u@\h \$(pwd | highlightrepo -y)]\n\[\e[32m\]\\$\[\e[0m\] "
```

## Installation

```cmd
Expand Down
2 changes: 2 additions & 0 deletions arg.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
type options struct {
color string
noTilde bool
nonTTY bool
}

func (cli *runner) parseArgs() *options {
Expand All @@ -33,6 +34,7 @@ func (cli *runner) parseArgs() *options {
var flagVersion bool
flag.StringVarP(&o.color, "color", "c", "cyan", "Color name to highlight")
flag.BoolVarP(&o.noTilde, "no-tilde", "t", false, "Not replace home dir path to tilda")
flag.BoolVarP(&o.nonTTY, "non-tty", "y", false, "Bypass the check for non-tty output streams")
flag.BoolVarP(&flagHelp, "help", "h", false, "Show help (This message) and exit")
flag.BoolVarP(&flagVersion, "version", "v", false, "Show version and build command info and exit")

Expand Down
5 changes: 5 additions & 0 deletions highlightrepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ func NewHighlightrepo(o *options) *highlightrepo {
h := &highlightrepo{
options: o,
}

if o.noTTY {

Check failure on line 32 in highlightrepo.go

View workflow job for this annotation

GitHub Actions / test-linux (ubuntu-latest, 1.21)

o.noTTY undefined (type *options has no field or method noTTY)

Check failure on line 32 in highlightrepo.go

View workflow job for this annotation

GitHub Actions / test-other (windows-latest)

o.noTTY undefined (type *options has no field or method noTTY)

Check failure on line 32 in highlightrepo.go

View workflow job for this annotation

GitHub Actions / test-linux (ubuntu-latest, 1.22)

o.noTTY undefined (type *options has no field or method noTTY)

Check failure on line 32 in highlightrepo.go

View workflow job for this annotation

GitHub Actions / test-other (macOS-latest)

o.noTTY undefined (type *options has no field or method noTTY)
color.NoColor = false
}

h.hlColor = colorpalette.Get(o.color)

return h
Expand Down

0 comments on commit 1cedd4e

Please sign in to comment.