Skip to content

Commit a5029f0

Browse files
committed
Add zsh completion, fix #4058
1 parent 9422915 commit a5029f0

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,8 @@ if(INSTALL_CONFIGS)
961961
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/tessdata/configs)
962962
install(FILES ${TESSERACT_TESSCONFIGS}
963963
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/tessdata/tessconfigs)
964+
install(FILES contrib/completions/zsh/_tesseract
965+
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/zsh/site-functions)
964966
endif()
965967

966968
# ##############################################################################

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ACLOCAL_AMFLAGS = -I m4
55

66
CLEANFILES =
77

8-
SUBDIRS = . tessdata
8+
SUBDIRS = . tessdata contrib
99

1010
EXTRA_DIST = README.md LICENSE
1111
EXTRA_DIST += aclocal.m4 config configure.ac autogen.sh

contrib/Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
zshcompletiondir = @datadir@/zsh/site-functions
2+
zshcompletion_DATA = completions/zsh/_tesseract
3+
4+
EXTRA_DIST = $(zshcompletion_DATA)

contrib/completions/zsh/_tesseract

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#compdef tesseract
2+
3+
local psm=(
4+
'0\:Orientation\ and\ script\ detection\ \(OSD\)\ only'
5+
'1\:Automatic\ page\ segmentation\ with\ OSD'
6+
'2\:Automatic\ page\ segmentation,\ but\ no\ OSD,\ or\ OCR\ \(not\ implemented\)'
7+
'3\:Fully\ automatic\ page\ segmentation,\ but\ no\ OSD\ \(Default\)'
8+
'4\:Assume\ a\ single\ column\ of\ text\ of\ variable\ sizes'
9+
'5\:Assume\ a\ single\ uniform\ block\ of\ vertically\ aligned\ text'
10+
'6\:Assume\ a\ single\ uniform\ block\ of\ text'
11+
'7\:Treat\ the\ image\ as\ a\ single\ text\ line'
12+
'8\:Treat\ the\ image\ as\ a\ single\ word'
13+
'9\:Treat\ the\ image\ as\ a\ single\ word\ in\ a\ circle'
14+
'10\:Treat\ the\ image\ as\ a\ single\ character'
15+
'11\:Sparse\ text.\ Find\ as\ much\ text\ as\ possible\ in\ no\ particular\ order'
16+
'12\:Sparse\ text\ with\ OSD'
17+
'13\:Raw\ line.\ Treat\ the\ image\ as\ a\ single\ text\ line,\ bypassing\ hacks\ that\ are\ Tesseract-specific'
18+
)
19+
local oem=(
20+
'0\:Legacy\ engine\ only'
21+
'1\:Neural\ nets\ LSTM\ engine\ only'
22+
'2\:Legacy\ +\ LSTM\ engines'
23+
'3\:Default,\ based\ on\ what\ is\ available'
24+
)
25+
local options=(
26+
"(- : *)"{-h,--help}"[Show minimal help message]"
27+
"(- : *)"--help-extra"[Show extra help for advanced users]"
28+
"(- : *)"--help-psm"[Show page segmentation modes]"
29+
"(- : *)"--help-oem"[Show OCR Engine modes]"
30+
"(- : *)"{-v,--version}"[Show version information]"
31+
"(- : *)"--list-langs"[List available languages for tesseract engine]"
32+
"(- : *)"--print-fonts-table"[Print tesseract fonts table]"
33+
"(- : *)"--print-parameters"[Print tesseract parameters]"
34+
--tessdata-dir"[Specify the location of tessdata path]: :_dirs"
35+
--user-words"[Specify the location of user words file]: :_files"
36+
--user-patterns"[Specify the location of user patterns file]: :_files"
37+
--dpi"[Specify DPI for input image]:VALUE"
38+
--loglevel"[Specify logging level]:LEVEL:(ALL TRACE DEBUG INFO WARN ERROR FATAL OFF)"
39+
-l"[Specify language(s) used for OCR]:LANG:($(tesseract --list-langs | tail -n+2))"
40+
'*'-c"[Set value for config variables]:VAR=VALUE"
41+
--psm"[Specify page segmentation mode]:Page segmentation mode:(($psm))"
42+
--oem"[Specify OCR Engine mode]:OCR Engine mode:(($oem))"
43+
)
44+
45+
_arguments -s -S $options ':imagename:_files' ':outputbase:_files' '*:config:_files'

0 commit comments

Comments
 (0)