A utility to autocomplete words in the GUI.
Want to contribute? See this.
Click the image to view a GIF demo.
Licensed under the GNU GPL 3. TextSuggest is free as in freedom.
An alternative background service, textsuggestd that intelligently offers completions when appropriate, without the need of pressing a shortcut is in development.
Ubuntu and Debian
Now, see Post-install
Now, see Post-install
Make sure you have all the requirements (
Run the included install script with
Now, see Post-install
Bind the command
textsuggest --auto-selection to a keyboard shortcut. Type a word, press the shortcut and ... TextSuggest will give you suggestions!
This offers the most basic use of TextSuggest. For more, see options and browse through the rest of this page.
If you installed it using packages, use your system's package manager.
sudo ./install.sh --uninstall.
Also documented in the manual page:
man textsuggest and
--help: Print out a help message.
--word word ...: Specify word to give suggestions for. If not specified, taken from X11 selection. Ignored if
--all-words: Give all the suggestions. Then you can search through them etc.
--font font: Specify font to use for Rofi. Format: FontName (Weight) (Size). Default: Varies based on language.
--no-history: Disable the storage of frequently-used words in
--language languages ...: Specify language to use. Appropriate language will be detected if not specified. If detection fails too, English will be used.
--auto-selection [beginning|middle|end]: Auto-select word under cursor and suggest. See Auto-selection.
--no-processing: Disable use of processors
--rofi-options options ...: Specify additional options for Rofi.
--exit-if-no-words-found: Exit if no words are found (
ERR_NOWORDS, return code 1) instead of restarting in
--version: Print out version and license information.
TextSuggest can handle a range of expansions. It can also be extended.
Simply add them to
~/.config/textsuggest/Custom_Words.txt like this:
custom=My custom Expansion!
and whenever 'custom' is typed, 'My custom Expansion!' will be inserted.
Inserts the output of a command:
when typed into a TextSuggest window, will insert output of
Custom words + Commands
and whenever you type 'custom' into TextSuggest, the output of
command --opts will be inserted.
Simply type into TextSuggest:
%2 + 3
And '5' will be inserted. You can do any math expression that Python supports.
You can also use any function in the Python
math library, for example
%sqrt(25) for √25.
Custom Words + Math
And whenever you type 'custom' into TextSuggest, 5 will be inserted.
TextSuggest supports powerful processors for extensions.
You can see this in TextSuggest output:
$ textsuggest --all-words Running in insert mode. Chosen word: %2 + 3 Using processor math_expression from /usr/share/textsuggest/processors/math_expression.py Processed: 5
Making your own extension
A processor is a simple Python script, that must define two functions,
process(). Look into this example:
def matches(text): # Return whether this processor should process 'text' or not. (True or False) # For example, the command processor has it like this: # return True if text.startswith('#') else False def process(text): # Do something with 'text' and return it. # You *must* return a string. # This is what will be finally typed.
Make one based on the sample above, and place it in
~/.config/textsuggest/processors/ (file must end with
~/.config/textsuggest/processors take precedence over those in
/usr/share/textsuggest/processors, in case of a name or match conflict.
You can set the order of loading of processors by creating a file called
load-order.txt in the processor directory, which should have
a newline-separated list of processors. The processors will then load in that order.
English and Bangla dictionaries are provided by default.
For other languages, follow these steps:
Get a suitable dictionary/wordlist for your language. Search online for " wordlist" or " dictionary".
Put that dictionary into a text file in
/usr/share/textsuggest/dictionarieswith its name being your language's name and extension being
.txt(English name, like "German.txt" instead of "Deutsch.txt").
A suitable font should be auto-detected. If not, pass a suitable font with the
Language should be auto-detected. If not, manually set language using the
Auto-select and suggest
This feature allows you to get suggestions for the word being typed, without having to select it. Save more keystrokes!
--auto-selection option to TextSuggest.
You can change the way
--auto-selection selects words.
--auto-selectionto assume that text-cursor is at beginning of word.
--auto-selectionto assume that text-cursor is in the middle of word.
--auto-selectionto assume that text-cursor is at end of the word. This is the default.
TextSuggest offers powerful search, thanks to Rofi.
- Fuzzy search: No need to type the complete word. Just type parts of it (separated by spaces).
- Globbing: Use wildcards like
ERR_NOWORDS: Caused when no suggestions are found. Return value: 1. NOTE: Suppressed and program restarted in
ERR_REJECTED: Caused when TextSuggest is cancelled by user (for example, by pressing
Esc). Return value: 2.
ERR_EXPRESSION: Caused when evaluating a math expression results in a Python error. (Usually
SyntaxError). Full traceback of said error is writted to stderr. Return value: 3.
Internally, TextSuggest has two modes:
- Provides completion for a specific word:
- Provides a list of all words:
You will see this in TextSuggest output:
$ textsuggest Running in replace mode. ...
textsuggestd is a work-in-progress background service that automatically launches TextSuggest when appropriate.
It is an effort to achieve TextSuggest's final goal: to be like the suggestions on mobile phones, which appear without stealing focus and disrupting typing, and without having to press shortcuts.
WARNING: It is currently unusable. Do not run. However, if you want to alpha-test, see below.
WARNING: It is currently unusable. Run at risk. See escaping.
$ ./textsuggestd &
Get to a terminal somehow (TTY, maybe?) and run:
for i in $(pgrep python3); do ps -fp $i | grep 'textsuggestd' && kill $i done