From 5b7fdb2e932ec91648fe07774fa556fb953a68cb Mon Sep 17 00:00:00 2001 From: Roman Komkov Date: Thu, 1 Jun 2023 01:00:53 +0200 Subject: [PATCH 1/5] Refactoring --- def-matcher.go | 27 +++++++++++++++-------- go.mod | 13 +++++++++++- go.sum | 12 +++++++++++ matcher/matcher.go | 26 ++++++++++------------- matcher/matcher_test.go | 47 ++++++++++++++++++++++++++--------------- model/aliasdef.go | 4 ++-- parser/parser.go | 6 +++--- parser/parser_test.go | 6 +++--- 8 files changed, 91 insertions(+), 50 deletions(-) diff --git a/def-matcher.go b/def-matcher.go index f2368e7..68ed880 100644 --- a/def-matcher.go +++ b/def-matcher.go @@ -4,6 +4,7 @@ import ( "bufio" "fmt" "os" + "strings" "github.com/sei40kr/zsh-fast-alias-tips/matcher" "github.com/sei40kr/zsh-fast-alias-tips/model" @@ -19,21 +20,29 @@ func main() { os.Exit(1) } - defs := make([]model.AliasDef, 0, 512) + aliases := make([]model.AliasDef, 0, 1024) + excludes := strings.Split(os.Getenv("ZSH_FAST_ALIAS_TIPS_EXCLUDES"), " ") scanner := bufio.NewScanner(bufio.NewReaderSize(os.Stdin, 1024)) for scanner.Scan() { - line := scanner.Text() - defs = append(defs, parser.Parse(line)) + alias := parser.Parse(scanner.Text()) + + skip := false + + for _, exclude := range excludes { + if exclude == alias.Name { + skip = true + } + } + + if !skip { + aliases = append(aliases, alias) + } } command := os.Args[1] - match, isFullMatch := matcher.Match(defs, command) + match := matcher.Match(aliases, command) if match != nil { - if isFullMatch { - fmt.Printf("%s\n", match.Name) - } else { - fmt.Printf("%s%s\n", match.Name, command[len(match.Abbr):]) - } + fmt.Printf("%s%s\n", match.Name, command[len(match.Expanded):]) } } diff --git a/go.mod b/go.mod index 0204bb3..a1ff8c5 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,14 @@ module github.com/sei40kr/zsh-fast-alias-tips -require github.com/stretchr/testify v1.4.0 +go 1.20 + +require github.com/stretchr/testify v1.8.4 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/stretchr/objx v0.5.0 // indirect + gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 // indirect + gopkg.in/yaml.v2 v2.2.2 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/go.sum b/go.sum index adc7cd7..34b6a11 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,18 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/matcher/matcher.go b/matcher/matcher.go index 260897a..ce88c85 100644 --- a/matcher/matcher.go +++ b/matcher/matcher.go @@ -8,39 +8,35 @@ import ( "github.com/sei40kr/zsh-fast-alias-tips/model" ) -func Match(defs []model.AliasDef, command string) (*model.AliasDef, bool) { +func Match(defs []model.AliasDef, command string) *model.AliasDef { sort.Slice(defs, func(i, j int) bool { - return len(defs[j].Abbr) <= len(defs[i].Abbr) + return len(defs[j].Expanded) <= len(defs[i].Expanded) }) var candidate model.AliasDef - isFullMatch := false - for true { + for { var match model.AliasDef for _, def := range defs { - if command == def.Abbr { - match = def - isFullMatch = true - break - } else if strings.HasPrefix(command, def.Abbr) { + if command == def.Expanded || strings.HasPrefix(command, def.Expanded) { match = def break } } if match != (model.AliasDef{}) { - command = fmt.Sprintf("%s%s", match.Name, command[len(match.Abbr):]) + command = fmt.Sprintf("%s%s", match.Name, command[len(match.Expanded):]) candidate = match - } else { - break + continue } + + break } if candidate != (model.AliasDef{}) { - return &candidate, isFullMatch - } else { - return nil, false + return &candidate } + + return nil } diff --git a/matcher/matcher_test.go b/matcher/matcher_test.go index ac9c837..5b825e9 100644 --- a/matcher/matcher_test.go +++ b/matcher/matcher_test.go @@ -9,53 +9,66 @@ import ( var mockAliasDefs = []model.AliasDef{ { - Name: "dk", - Abbr: "docker", + Name: "dk", + Expanded: "docker", }, { - Name: "gb", - Abbr: "git branch", + Name: "gb", + Expanded: "git branch", }, { - Name: "gco", - Abbr: "git checkout", + Name: "gco", + Expanded: "git checkout", }, { - Name: "gcb", - Abbr: "git checkout -b", + Name: "gcb", + Expanded: "git checkout -b", }, { - Name: "ls", - Abbr: "ls -G", + Name: "ls", + Expanded: "ls -G", }, { - Name: "ll", - Abbr: "ls -lh", + Name: "ll", + Expanded: "ls -lh", + }, + { + Name: "sl", + Expanded: "ls", + }, + { + Name: "l", + Expanded: "ls", }, } func TestMatch_NoMatches(t *testing.T) { - candidate, _ := Match(mockAliasDefs, "cd ..") + candidate := Match(mockAliasDefs, "cd ..") assert.Nil(t, candidate, "should return nil when no matches found") } func TestMatch_SingleToken(t *testing.T) { - candidate, _ := Match(mockAliasDefs, "docker") + candidate := Match(mockAliasDefs, "docker") assert.Equal(t, candidate.Name, "dk") } func TestMatch_MultipleTokens(t *testing.T) { - candidate, _ := Match(mockAliasDefs, "git branch") + candidate := Match(mockAliasDefs, "git branch") assert.Equal(t, candidate.Name, "gb") } func TestMatch_MultipleMatches(t *testing.T) { - candidate, _ := Match(mockAliasDefs, "git checkout -b") + candidate := Match(mockAliasDefs, "git checkout -b") assert.Equal(t, candidate.Name, "gcb", "should return the alias definition that has the longest abbreviation when multiple matches found") } func TestMatch_RecursiveDefs(t *testing.T) { - candidate, _ := Match(mockAliasDefs, "ls -G -lh") + candidate := Match(mockAliasDefs, "ls -G -lh") assert.Equal(t, candidate.Name, "ll", "should apply aliases recursively") } + +func TestMatch_AliasSameOrLonger(t *testing.T) { + candidate := Match(mockAliasDefs, "ls /") + assert.Nil(t, candidate, "should return nil when alias length is same or longer") +} diff --git a/model/aliasdef.go b/model/aliasdef.go index 7db1736..a569bad 100644 --- a/model/aliasdef.go +++ b/model/aliasdef.go @@ -1,6 +1,6 @@ package model type AliasDef struct { - Name string - Abbr string + Name string + Expanded string } diff --git a/parser/parser.go b/parser/parser.go index 015f544..e0dffac 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -4,7 +4,7 @@ import "github.com/sei40kr/zsh-fast-alias-tips/model" func Parse(line string) model.AliasDef { alias := make([]rune, 0, 1024) - abbr := make([]rune, 0, 1024) + expanded := make([]rune, 0, 1024) afterEscape := false inQuote := false @@ -25,11 +25,11 @@ func Parse(line string) model.AliasDef { } else if !inRightExp { alias = append(alias, aRune) } else { - abbr = append(abbr, aRune) + expanded = append(expanded, aRune) } afterEscape = false } - return model.AliasDef{Name: string(alias), Abbr: string(abbr)} + return model.AliasDef{Name: string(alias), Expanded: string(expanded)} } diff --git a/parser/parser_test.go b/parser/parser_test.go index 6570739..b2fd200 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -8,13 +8,13 @@ import ( ) func TestParse_NoQuotesInRightExp(t *testing.T) { - assert.Equal(t, Parse("dk=docker"), model.AliasDef{Name: "dk", Abbr: "docker"}) + assert.Equal(t, Parse("dk=docker"), model.AliasDef{Name: "dk", Expanded: "docker"}) } func TestParse_QuotesInRightExp(t *testing.T) { - assert.Equal(t, Parse("gb='git branch'"), model.AliasDef{Name: "gb", Abbr: "git branch"}) + assert.Equal(t, Parse("gb='git branch'"), model.AliasDef{Name: "gb", Expanded: "git branch"}) } func TestParse_QuotesInBothExps(t *testing.T) { - assert.Equal(t, Parse("'g cb'='git checkout -b'"), model.AliasDef{Name: "g cb", Abbr: "git checkout -b"}) + assert.Equal(t, Parse("'g cb'='git checkout -b'"), model.AliasDef{Name: "g cb", Expanded: "git checkout -b"}) } From 0e824b66692f92440032be3ae7e09540a13e50dc Mon Sep 17 00:00:00 2001 From: decayofmind Date: Thu, 1 Jun 2023 01:46:20 +0200 Subject: [PATCH 2/5] Remove goreleaser From 7e122b838d2bda9717727a10e0ac0e8034d27532 Mon Sep 17 00:00:00 2001 From: decayofmind Date: Sat, 3 Jun 2023 15:48:39 +0200 Subject: [PATCH 3/5] Main refactoring --- .github/dependabot.yaml | 6 ++++ .github/workflows/ci-on-push.yml | 17 ---------- .github/workflows/ci.yaml | 27 +++++++++++++++ .github/workflows/release.yaml | 33 +++++++++++++++++++ .gitignore | 2 +- .golangci.yaml | 14 ++++++++ .goreleaser.yaml | 22 +++++++++++++ .goreleaser.yml | 14 -------- LICENSE | 1 + Makefile | 12 ++++--- README.md | 19 ++++------- build/.gitkeep | 0 .../zsh-alias-matcher/main.go | 9 ++--- go.mod | 2 +- {matcher => pkg/matcher}/matcher.go | 2 +- {matcher => pkg/matcher}/matcher_test.go | 2 +- {model => pkg/model}/aliasdef.go | 0 {parser => pkg/parser}/parser.go | 2 +- {parser => pkg/parser}/parser_test.go | 2 +- ...ugin.zsh => zsh-fast-alias-tips.plugin.zsh | 6 ++-- 20 files changed, 129 insertions(+), 63 deletions(-) create mode 100644 .github/dependabot.yaml delete mode 100644 .github/workflows/ci-on-push.yml create mode 100644 .github/workflows/ci.yaml create mode 100644 .github/workflows/release.yaml create mode 100644 .golangci.yaml create mode 100644 .goreleaser.yaml delete mode 100644 .goreleaser.yml delete mode 100644 build/.gitkeep rename def-matcher.go => cmd/zsh-alias-matcher/main.go (77%) rename {matcher => pkg/matcher}/matcher.go (92%) rename {matcher => pkg/matcher}/matcher_test.go (96%) rename {model => pkg/model}/aliasdef.go (100%) rename {parser => pkg/parser}/parser.go (91%) rename {parser => pkg/parser}/parser_test.go (90%) rename fast-alias-tips.plugin.zsh => zsh-fast-alias-tips.plugin.zsh (74%) diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 0000000..f1b219b --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci-on-push.yml b/.github/workflows/ci-on-push.yml deleted file mode 100644 index 037462d..0000000 --- a/.github/workflows/ci-on-push.yml +++ /dev/null @@ -1,17 +0,0 @@ -on: - push: - tags: - - v* - -jobs: - release: - runs-on: ubuntu-18.04 - container: - image: golang:1.11 - steps: - - uses: actions/checkout@v2 - - - name: 'Run GoReleaser' - env: - GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }} - uses: goreleaser/goreleaser-action@v1 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..dec73f8 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,27 @@ +--- +on: + - pull_request + +permissions: + contents: read + pull-requests: read +jobs: + ci: + name: lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-go@v4 + with: + go-version-file: go.mod + cache: false + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3 + with: + only-new-issues: true + + - name: Test + run: make test diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..45dc65b --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,33 @@ +--- +on: + push: + tags: + - "v*" + +permissions: + contents: write + packages: write + +jobs: + release: + runs-on: ubuntu-latest + env: + REGISTRY: ghcr.io + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version-file: go.mod + + - name: Release Binaries + uses: goreleaser/goreleaser-action@v4 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index ab071f6..b365835 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ *.dll *.so *.dylib -/build/def-matcher +/build/ # Test binary, built with `go test -c` *.test diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..5acb16d --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,14 @@ +--- +run: + timeout: 5m +linters: + disable-all: true + enable: + - errcheck + - gofmt + - gosimple + - govet + - ineffassign + - staticcheck + - typecheck + - unused diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..dea4ad9 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,22 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +--- +before: + hooks: + - go mod tidy + +builds: + - main: cmd/zsh-alias-matcher/main.go + binary: zsh-alias-matcher + goos: + - windows + - darwin + - linux + goarch: + - amd64 + - arm64 + +checksum: + name_template: checksums.txt + +changelog: + sort: asc diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index f3ec307..0000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,14 +0,0 @@ -builds: - - main: def-matcher.go - binary: def-matcher - goos: - - windows - - darwin - - linux - goarch: - - amd64 - -release: - github: - owner: sei40kr - name: fast-alias-tips-bin diff --git a/LICENSE b/LICENSE index 778412c..cc6f4d3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License Copyright (c) 2019 Seong Yong-ju +Copyright (c) 2023 Roman Komkov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 29e77ed..47183cd 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,11 @@ -.PHONY: all -all: - go build -o build/def-matcher def-matcher.go +.PHONY: build +build: + GO111MODULE=on go build -o build/zsh-alias-matcher ./cmd/zsh-alias-matcher + .PHONY: test test: - go test -v def-matcher.go def-matcher_test.go + go test -v -race -buildvcs ./... + .PHONY: clean clean: - rm -f build/def-matcher + rm -f build/* diff --git a/README.md b/README.md index 38a07eb..ac4315f 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Helps you remembering the aliases you defined once. +sei40kr/fast-alias-tips-bin + Written in zsh and Go. Ported from [djui/alias-tips](https://github.com/djui/alias-tips). ## Example @@ -27,16 +29,9 @@ zinit light sei40kr/fast-alias-tips-bin zinit light sei40kr/zsh-fast-alias-tips ``` -### Install with [zplug](https://github.com/zplug/zplug) - -```sh -zplug sei40kr/fast-alias-tips-bin, from:gh-r, as:command, rename-to:def-matcher -zplug sei40kr/zsh-fast-alias-tips -``` - -## Customization +## Configuration -| Variable | Default value | Description | -| :-- | :-- | :-- | -| `FAST_ALIAS_TIPS_PREFIX` | `"💡 $(tput bold)"` | The prefix of the Tips | -| `FAST_ALIAS_TIPS_SUFFIX` | `"$(tput sgr0)"` | The suffix of the Tips | +| Variable | Default value | Description | +| :-- | :-- | :-- | +| `ZSH_FAST_ALIAS_TIPS_PREFIX` | `"💡 $(tput bold)"` | The prefix of the Tips | +| `ZSH_FAST_ALIAS_TIPS_SUFFIX` | `"$(tput sgr0)"` | The suffix of the Tips | diff --git a/build/.gitkeep b/build/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/def-matcher.go b/cmd/zsh-alias-matcher/main.go similarity index 77% rename from def-matcher.go rename to cmd/zsh-alias-matcher/main.go index 68ed880..f8d3798 100644 --- a/def-matcher.go +++ b/cmd/zsh-alias-matcher/main.go @@ -6,14 +6,11 @@ import ( "os" "strings" - "github.com/sei40kr/zsh-fast-alias-tips/matcher" - "github.com/sei40kr/zsh-fast-alias-tips/model" - "github.com/sei40kr/zsh-fast-alias-tips/parser" + "github.com/decayofmind/zsh-fast-alias-tips/pkg/matcher" + "github.com/decayofmind/zsh-fast-alias-tips/pkg/model" + "github.com/decayofmind/zsh-fast-alias-tips/pkg/parser" ) -// def-matcher.go -// author: Seong Yong-ju - func main() { if len(os.Args) != 2 { fmt.Fprintln(os.Stderr, "Invalid number of arguments") diff --git a/go.mod b/go.mod index a1ff8c5..ff52fa2 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/sei40kr/zsh-fast-alias-tips +module github.com/decayofmind/zsh-fast-alias-tips go 1.20 diff --git a/matcher/matcher.go b/pkg/matcher/matcher.go similarity index 92% rename from matcher/matcher.go rename to pkg/matcher/matcher.go index ce88c85..bf94240 100644 --- a/matcher/matcher.go +++ b/pkg/matcher/matcher.go @@ -5,7 +5,7 @@ import ( "sort" "strings" - "github.com/sei40kr/zsh-fast-alias-tips/model" + "github.com/decayofmind/zsh-fast-alias-tips/pkg/model" ) func Match(defs []model.AliasDef, command string) *model.AliasDef { diff --git a/matcher/matcher_test.go b/pkg/matcher/matcher_test.go similarity index 96% rename from matcher/matcher_test.go rename to pkg/matcher/matcher_test.go index 5b825e9..2f2115f 100644 --- a/matcher/matcher_test.go +++ b/pkg/matcher/matcher_test.go @@ -3,7 +3,7 @@ package matcher import ( "testing" - "github.com/sei40kr/zsh-fast-alias-tips/model" + "github.com/decayofmind/zsh-fast-alias-tips/pkg/model" "github.com/stretchr/testify/assert" ) diff --git a/model/aliasdef.go b/pkg/model/aliasdef.go similarity index 100% rename from model/aliasdef.go rename to pkg/model/aliasdef.go diff --git a/parser/parser.go b/pkg/parser/parser.go similarity index 91% rename from parser/parser.go rename to pkg/parser/parser.go index e0dffac..b005062 100644 --- a/parser/parser.go +++ b/pkg/parser/parser.go @@ -1,6 +1,6 @@ package parser -import "github.com/sei40kr/zsh-fast-alias-tips/model" +import "github.com/decayofmind/zsh-fast-alias-tips/pkg/model" func Parse(line string) model.AliasDef { alias := make([]rune, 0, 1024) diff --git a/parser/parser_test.go b/pkg/parser/parser_test.go similarity index 90% rename from parser/parser_test.go rename to pkg/parser/parser_test.go index b2fd200..0c35bee 100644 --- a/parser/parser_test.go +++ b/pkg/parser/parser_test.go @@ -3,7 +3,7 @@ package parser import ( "testing" - "github.com/sei40kr/zsh-fast-alias-tips/model" + "github.com/decayofmind/zsh-fast-alias-tips/pkg/model" "github.com/stretchr/testify/assert" ) diff --git a/fast-alias-tips.plugin.zsh b/zsh-fast-alias-tips.plugin.zsh similarity index 74% rename from fast-alias-tips.plugin.zsh rename to zsh-fast-alias-tips.plugin.zsh index bb75efd..a8021c1 100644 --- a/fast-alias-tips.plugin.zsh +++ b/zsh-fast-alias-tips.plugin.zsh @@ -1,8 +1,8 @@ # fast-alias-tips.plugin.zsh # author: Seong Yong-ju -: ${FAST_ALIAS_TIPS_PREFIX:="💡 $(tput bold)"} -: ${FAST_ALIAS_TIPS_SUFFIX:="$(tput sgr0)"} +: ${ZSH_FAST_ALIAS_TIPS_PREFIX:="💡 $(tput bold)"} +: ${ZSH_FAST_ALIAS_TIPS_SUFFIX:="$(tput sgr0)"} __fast_alias_tips_preexec() { local cmd="$1" @@ -20,7 +20,7 @@ __fast_alias_tips_preexec() { return fi - echo "${FAST_ALIAS_TIPS_PREFIX}${suggested}${FAST_ALIAS_TIPS_SUFFIX}" + echo "${ZSH_FAST_ALIAS_TIPS_PREFIX}${suggested}${ZSH_FAST_ALIAS_TIPS_SUFFIX}" } autoload -Uz add-zsh-hook From 7ee2c827d1a89b6c48d0d5b21d56cafe6b83b69a Mon Sep 17 00:00:00 2001 From: decayofmind Date: Sat, 3 Jun 2023 15:55:37 +0200 Subject: [PATCH 4/5] Fix tests --- pkg/matcher/matcher_test.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/pkg/matcher/matcher_test.go b/pkg/matcher/matcher_test.go index 2f2115f..c3518c0 100644 --- a/pkg/matcher/matcher_test.go +++ b/pkg/matcher/matcher_test.go @@ -32,10 +32,6 @@ var mockAliasDefs = []model.AliasDef{ Name: "ll", Expanded: "ls -lh", }, - { - Name: "sl", - Expanded: "ls", - }, { Name: "l", Expanded: "ls", @@ -67,8 +63,3 @@ func TestMatch_RecursiveDefs(t *testing.T) { candidate := Match(mockAliasDefs, "ls -G -lh") assert.Equal(t, candidate.Name, "ll", "should apply aliases recursively") } - -func TestMatch_AliasSameOrLonger(t *testing.T) { - candidate := Match(mockAliasDefs, "ls /") - assert.Nil(t, candidate, "should return nil when alias length is same or longer") -} From 17581225c9251b1cadb1460286ff88b2b6477a24 Mon Sep 17 00:00:00 2001 From: decayofmind Date: Sat, 3 Jun 2023 15:57:36 +0200 Subject: [PATCH 5/5] Remove job name --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dec73f8..af71dc5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,7 +7,6 @@ permissions: pull-requests: read jobs: ci: - name: lint runs-on: ubuntu-latest steps: - name: Checkout