Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.7.0 #29

Merged
merged 10 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/ask_question.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Question
about: Ask a question.
title: ''
title: ""
labels: question
assignees: ''

assignees: ""
---

**Question**
Expand Down
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
title: ""
labels: bug
assignees: Gazorby

---

**Describe the bug**
Expand All @@ -20,8 +19,9 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**System (please complete the following information):**
- fish version
- Distribution `cat /etc/os-release`

- fish version
- Distribution `cat /etc/os-release`

**Additional context**
Add any other context about the problem here.
5 changes: 2 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
title: ""
labels: enhancement
assignees: ''

assignees: ""
---

**Is your feature request related to a problem? Please describe.**
Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI

on:
push:
branches: [main]
pull_request:

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest, ubuntu-latest]

steps:
- uses: actions/checkout@v3
- uses: fish-actions/install-fish@v1.1.0

- name: Install abbreviation-tips with Fisher
uses: fish-shop/install-plugin@v1
with:
plugin-manager: fisher
plugins: gazorby/fish-abbreviation-tips

- name: Run Fishtape tests
uses: fish-shop/run-fishtape-tests@v1
with:
pattern: tests/**.fish

syntax-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: fish-actions/install-fish@v1

- uses: fish-actions/syntax-check@v1

# Check Fish format
format-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: fish-actions/install-fish@v1

- uses: fish-actions/format-check@v1

# Check Markdown and Yaml format
prettier:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actionsx/prettier@v2
with:
args: --check .
42 changes: 0 additions & 42 deletions .github/workflows/tests.yml

This file was deleted.

27 changes: 27 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-toml
- id: mixed-line-ending
- id: check-case-conflict
- id: check-merge-conflict
- id: check-docstring-first
- id: check-added-large-files
- id: check-executables-have-shebangs
- id: debug-statements
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: trailing-whitespace

- repo: https://github.com/hugoh/pre-commit-fish.git
rev: v1.2
hooks:
- id: fish_syntax
- id: fish_indent

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v2.7.1"
hooks:
- id: prettier
types: [markdown]
39 changes: 21 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,53 @@
## 0.5.1 (2020-05-12)
- ♻️ ref: prefix with '__' for private scope

- ♻️ ref: prefix with '\_\_' for private scope
- 🐛 fix(regex): don't treat '-' as a word separator

## 0.5.0 (2020-05-12)

- ✨ feat: customize regexes
- ♻️ ref: use verbose conditional operators

## 0.4.0 (2020-04-20)

- ⚡ perf: update abbreviations list incrementally

# [0.3.1](https://github.com/Gazorby/abbr-tips/compare/v0.3.0...v0.3.1) (2020-04-17)

### 🐛 Bug Fixes

* fix: test variable existence instead of value ([f33cf23](https://github.com/Gazorby/abbr-tips/commit/f33cf23))
* fix: update function to erase on uninstall ([ba239d1](https://github.com/Gazorby/abbr-tips/commit/ba239d1))
- fix: test variable existence instead of value ([f33cf23](https://github.com/Gazorby/abbr-tips/commit/f33cf23))
- fix: update function to erase on uninstall ([ba239d1](https://github.com/Gazorby/abbr-tips/commit/ba239d1))

# [0.3.0](https://github.com/Gazorby/abbr-tips/compare/v0.2.0...v0.3.0) (2020-04-16)

### ♻️ Refactor

* refactor: remove flock dependency ([376072d](https://github.com/Gazorby/abbr-tips/commit/376072d))
- refactor: remove flock dependency ([376072d](https://github.com/Gazorby/abbr-tips/commit/376072d))

# [0.2.0](https://github.com/Gazorby/abbr-tips/compare/v0.1.0...v0.2.0) (2020-04-13)

### 🐛 Bug Fixes

* fix: don't use universal scope by default ([832691a](https://github.com/Gazorby/abbr-tips/commit/832691a))
* fix: erase functions on uninstall ([cd1a75a](https://github.com/Gazorby/abbr-tips/commit/cd1a75a))
* fix: fix uninstall function ([b58971f](https://github.com/Gazorby/abbr-tips/commit/b58971f))
* fix: still need univresal scope for abbr lists ([6a700a0](https://github.com/Gazorby/abbr-tips/commit/6a700a0))
- fix: don't use universal scope by default ([832691a](https://github.com/Gazorby/abbr-tips/commit/832691a))
- fix: erase functions on uninstall ([cd1a75a](https://github.com/Gazorby/abbr-tips/commit/cd1a75a))
- fix: fix uninstall function ([b58971f](https://github.com/Gazorby/abbr-tips/commit/b58971f))
- fix: still need univresal scope for abbr lists ([6a700a0](https://github.com/Gazorby/abbr-tips/commit/6a700a0))

# [0.1.0](https://github.com/Gazorby/abbr-tips/compare/f5ab8ed...v0.1.0) (2020-04-13)

### ✨ Features

* feat: customize tips prompt ([ae29fca](https://github.com/Gazorby/abbr-tips/commit/ae29fca))
* feat: customize tips update mode ([4681009](https://github.com/Gazorby/abbr-tips/commit/4681009))
* feat: don't show tips if an abbr was used ([5f2e6ac](https://github.com/Gazorby/abbr-tips/commit/5f2e6ac))
* feat: prettier tips ([f5ab8ed](https://github.com/Gazorby/abbr-tips/commit/f5ab8ed))
- feat: customize tips prompt ([ae29fca](https://github.com/Gazorby/abbr-tips/commit/ae29fca))
- feat: customize tips update mode ([4681009](https://github.com/Gazorby/abbr-tips/commit/4681009))
- feat: don't show tips if an abbr was used ([5f2e6ac](https://github.com/Gazorby/abbr-tips/commit/5f2e6ac))
- feat: prettier tips ([f5ab8ed](https://github.com/Gazorby/abbr-tips/commit/f5ab8ed))

### 🐛 Bug Fixes

* fix: check for abbr status in on whitespace input ([421ede5](https://github.com/Gazorby/abbr-tips/commit/421ede5))
* fix: delete keybindings when uninstalling ([11ce0ae](https://github.com/Gazorby/abbr-tips/commit/11ce0ae))
* fix: don't show tips if abbr was used and options added ([a2b5214](https://github.com/Gazorby/abbr-tips/commit/a2b5214))
* fix: prompt variable not properly set ([1cc43e0](https://github.com/Gazorby/abbr-tips/commit/1cc43e0))
* fix: properly resetting abbr status ([59e90e2](https://github.com/Gazorby/abbr-tips/commit/59e90e2))
* fix: reset abbr status after displaying tip ([46c70c1](https://github.com/Gazorby/abbr-tips/commit/46c70c1))
- fix: check for abbr status in on whitespace input ([421ede5](https://github.com/Gazorby/abbr-tips/commit/421ede5))
- fix: delete keybindings when uninstalling ([11ce0ae](https://github.com/Gazorby/abbr-tips/commit/11ce0ae))
- fix: don't show tips if abbr was used and options added ([a2b5214](https://github.com/Gazorby/abbr-tips/commit/a2b5214))
- fix: prompt variable not properly set ([1cc43e0](https://github.com/Gazorby/abbr-tips/commit/1cc43e0))
- fix: properly resetting abbr status ([59e90e2](https://github.com/Gazorby/abbr-tips/commit/59e90e2))
- fix: reset abbr status after displaying tip ([46c70c1](https://github.com/Gazorby/abbr-tips/commit/46c70c1))
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ You can use (and enhance!) scripts in `test` folder to test your code. You need
## IDE

If you are using Visual Studio Code, i recommend these extensions :

- [fish-vscode](https://marketplace.visualstudio.com/items?itemName=skyapps.fish-vscode) for syntax highlighting
- [fish-ide](https://marketplace.visualstudio.com/items?itemName=lunaryorn.fish-ide) for syntax errors checking
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ gcm => git commit -m
So you want a tip when typing `git commit -m "my commit"`, but the command doesn't match exactly `git commit -m`.
To tackle this, we have a default regex that will match commands with arguments removed, so your `git commit -m "my commit"` will be tested as `git commit -m`.

You can add such regexes to the `ABBR_TIPS_REGEXES` list, and they will be tested in the order in which they have been added (see [default configuration](#default-configuration)). Matching is lazy, so if the string extracted with the first regex matches an abbreviation/alias, it won't go further. Remember that only the *first matching group* will be tested. (so you must have at least one per regex)
You can add such regexes to the `ABBR_TIPS_REGEXES` list, and they will be tested in the order in which they have been added (see [default configuration](#default-configuration)). Matching is lazy, so if the string extracted with the first regex matches an abbreviation/alias, it won't go further. Remember that only the _first matching group_ will be tested. (so you must have at least one per regex)

## 🎥 Behind the scenes

Expand All @@ -95,4 +95,5 @@ The plugin will create lists once during installation by calling `__abbr_tips_in
Inspired by [zsh-fast-alias-tips](https://github.com/sei40kr/zsh-fast-alias-tips) and [alias-tips](https://github.com/djui/alias-tips) zsh plugins

## 📝 License

[MIT](https://github.com/Gazorby/fish-abbreviation-tips/blob/master/LICENSE)
57 changes: 21 additions & 36 deletions conf.d/abbr_tips.fish
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
for mode in default insert
bind --mode $mode " " '__abbr_tips_bind_space'
bind --mode $mode \n '__abbr_tips_bind_newline'
bind --mode $mode \r '__abbr_tips_bind_newline'
bind --mode $mode " " __abbr_tips_bind_space
bind --mode $mode \n __abbr_tips_bind_newline
bind --mode $mode \r __abbr_tips_bind_newline
end

set -g __abbr_tips_used 0
Expand All @@ -21,23 +21,19 @@ function __abbr_tips_install --on-event abbr_tips_install
set -a ABBR_TIPS_REGEXES '(^(\s?(\w-?)+){1}).*'

set -Ux ABBR_TIPS_PROMPT "\n💡 \e[1m{{ .abbr }}\e[0m => {{ .cmd }}"
set -gx ABBR_TIPS_AUTO_UPDATE 'background'
set -gx ABBR_TIPS_AUTO_UPDATE background

# Locking mechanism
# Prevent this file to spawn more than one subshell
if test "$USER" != 'root'
fish -c '__abbr_tips_init' &
end
__abbr_tips_init
end

function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the current command"
set -l command (string split ' ' -- "$argv")
set -l cmd (string replace -r -a '\\s+' ' ' -- "$argv" )

# Update abbreviations lists when adding/removing abbreviations
if test "$command[1]" = "abbr"
if test "$command[1]" = abbr
# Parse args as abbr options
argparse --name 'abbr' --ignore-unknown 'a/add' 'e/erase' 'g/global' 'U/universal' -- $command
argparse --name abbr --ignore-unknown a/add e/erase g/global U/universal -- $command

if set -q _flag_a
and not contains -- "$argv[2]" $__ABBR_TIPS_KEYS
Expand All @@ -48,21 +44,18 @@ function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the
set -e __ABBR_TIPS_KEYS[$abb]
set -e __ABBR_TIPS_VALUES[$abb]
end
else if test "$command[1]" = "alias"
else if test "$command[1]" = alias
# Update abbreviations list when adding aliases
set -l alias_key
set -l alias_value

# Parse args as `alias` options
argparse --name 'alias' --ignore-unknown 's/save' -- $command
argparse --name alias --ignore-unknown s/save -- $command

if string match -q '*=*' -- "$argv[2]"
if test (count $argv) = 2
set command_split (string split '=' -- $argv[2])
set alias_key "a__$command_split[1]"
set alias_value $command_split[2]
set -a alias_value $command[3..-1]
end
set command_split (string split '=' -- $argv[2])
set alias_key "a__$command_split[1]"
set alias_value $command_split[2..-1]
else
set alias_key "a__$argv[2]"
set alias_value $argv[3..-1]
Expand All @@ -77,9 +70,9 @@ function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the
set -a __ABBR_TIPS_KEYS $alias_key
set -a __ABBR_TIPS_VALUES $alias_value
end
else if test "$command[1]" = "functions"
else if test "$command[1]" = functions
# Parse args as `functions` options
argparse --name 'functions' 'e/erase' -- $command
argparse --name functions e/erase -- $command

# Update abbreviations list when removing aliases
if set -q _flag_e
Expand All @@ -102,7 +95,7 @@ function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the
return
else if string match -q -- "alias $cmd *" (alias)
return
else if test (type -t "$command[1]") = 'function'
else if test (type -t "$command[1]") = function
and count $ABBR_TIPS_ALIAS_WHITELIST >/dev/null
and not contains "$command[1]" $ABBR_TIPS_ALIAS_WHITELIST
return
Expand Down Expand Up @@ -136,20 +129,12 @@ function __abbr_tips --on-event fish_postexec -d "Abbreviation reminder for the
return
end

function __abbr_tips_update --on-event abbr_tips_update
__abbr_tips_clean
__abbr_tips_install
end

function __abbr_tips_uninstall --on-event abbr_tips_uninstall
bind --erase \n
bind --erase \r
bind --erase " "
set --erase __abbr_tips_used
set --erase __abbr_tips_run_once
set --erase __ABBR_TIPS_VALUES
set --erase __ABBR_TIPS_KEYS
set --erase ABBR_TIPS_PROMPT
set --erase ABBR_TIPS_AUTO_UPDATE
set --erase ABBR_TIPS_ALIAS_WHITELIST
set --erase ABBR_TIPS_REGEXES
__abbr_tips_clean
functions --erase __abbr_tips_init
functions --erase __abbr_tips_bind_newline
functions --erase __abbr_tips_bind_space
functions --erase __abbr_tips
end
2 changes: 1 addition & 1 deletion functions/__abbr_tips_bind_newline.fish
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ function __abbr_tips_bind_newline
set -g __abbr_tips_used 0
end
end
commandline -f 'execute'
commandline -f execute
end
Loading