aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-08-22 00:15:29 +0300
committerGitHub <noreply@github.com>2024-08-22 00:15:29 +0300
commit0992c51b0e2af9542dedfac84c27548293c94f91 (patch)
tree5d463dd0a895b42d4d288df1a3a32017b717c5b7
parent7cae6732391f48b7094ff5270b42941bf97c9210 (diff)
parentfc6339d449d9224b07174d01417a05fecedcf764 (diff)
downloadopenrussian-cli-0992c51b0e2af9542dedfac84c27548293c94f91.tar.gz
Merge pull request #6 from ehmry/fish
Add fish shell completion
-rw-r--r--Makefile5
-rw-r--r--README.md8
-rw-r--r--openrussian.fish7
3 files changed, 20 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index f0bfb1b..0fd7625 100644
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@ LUA ?= lua5.2
LUAC ?= luac5.2
BASH_COMPLETIONSDIR ?= $(shell pkg-config --variable=completionsdir bash-completion)
+FISH_COMPLETIONSDIR ?= $(shell pkg-config --variable=completionsdir fish)
ZSH_COMPLETIONSDIR ?= $(PREFIX)/share/zsh/site-functions
all : openrussian openrussian-sqlite3.db
@@ -49,6 +50,10 @@ ifneq ($(BASH_COMPLETIONSDIR),)
mkdir -p $(DESTDIR)$(BASH_COMPLETIONSDIR)
cp openrussian-completion.bash $(DESTDIR)$(BASH_COMPLETIONSDIR)/openrussian
endif
+ifneq ($(FISH_COMPLETIONSDIR),)
+ mkdir -p $(DESTDIR)$(FISH_COMPLETIONSDIR)
+ cp openrussian-completion.fish $(DESTDIR)$(FISH_COMPLETIONSDIR)/openrussian.fish
+endif
ifneq ($(ZSH_COMPLETIONSDIR),)
mkdir -p $(DESTDIR)$(ZSH_COMPLETIONSDIR)
cp openrussian-completion.zsh $(DESTDIR)$(ZSH_COMPLETIONSDIR)/_openrussian
diff --git a/README.md b/README.md
index af5e6f8..122e16e 100644
--- a/README.md
+++ b/README.md
@@ -132,6 +132,14 @@ sufficient to add the following to your `~/.zshrc`:
alias ru='openrussian -Lde -Len' ру='openrussian -Lde -Len'
+### Fish Aliases
+
+The Fish `alias` command creates local shell aliases or
+persistent aliases when invoked with the `--save` flag.
+
+ alias --save ru='openrussian -Lde -Len'
+ alias --save ру='openrussian -Lde -Len'
+
## Examples
A simple lookup:
diff --git a/openrussian.fish b/openrussian.fish
new file mode 100644
index 0000000..b704885
--- /dev/null
+++ b/openrussian.fish
@@ -0,0 +1,7 @@
+function __fish_complete_openrussian
+ set --local lang (commandline --current-process | string match --regex -- '-L..')
+ set --local token (commandline --current-process --current-token)
+ openrussian $lang -C $token 2>/dev/null
+end
+
+complete --command openrussian --arguments "-Len -Lde -V -p (__fish_complete_openrussian)"