Auto-completion for G'MIC commands?

Hi,

i’m using Version 3.2.6 (pre-release #230619)
Is there any difference between official release?

Side question :
How can I activate auto-completion for gmic commands?
On my PC running Linux Mint if i do :
gmic h r <TAB> it will give me a list of all the G’mic commands beginning with r, like resize, rotate, etc., which is very convenient to search for an unknown command.
But that’s not the case on my ArchLinux Arm, it doesn’t give me anything (zsh or bash)…
Probably a config thing but I don’t know where to look :frowning:

Today I learned material.

Anyways, can there be commands to return GUI header codes, CLI header code, CLI codes of command as a image? I’m thinking of converting my Python code which process clipboard of G’MIC codes into G’MIC code which calls Python.

I’m not imagining things :open_mouth: :

Yes, probably :slight_smile: (see Commits · GreycLab/gmic · GitHub to get the list of changes since that date). Version 3.2.6 is a very minor release, so with only a few changes compared to previous version 3.2.5.

Auto-completion in bash is managed by the file gmic-3.2.6/resources/gmic_bashcompletion.sh provided in the gmic_3.2.6.tar.gz archive.
This is a simple bash script, so you can first try:

$ . ./gmic_bashcompletion.sh

Then, if everything works, you can “install” it by moving/renaming this file as /usr/share/bash-completion/completions/gmic, to enable autocompletion of the gmic command by default.

1 Like

Hmm, this “gmic h r <tab>” trick doesn’t work here. I would love to get something like prawnsushi’s results with it.

Thanks, worked like a charm:)
Now i can tab my way through G’mic just like the (not so) old days!

(note : this works only for Bash, not zsh. But i changed my default shell to bash anyway)

EDIT: I build G’mic from git, but i didn’t see any gmic_bashcompletion.sh in the folders, so maybe i’ll have to build from the archive instead?.

1 Like

Try make bashcompletion

gosgood@bertha ~/git_repositories/gmic/src $ make bashcompletion
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Input custom command file 'gmic_stdlib.gmic' (2410 replaced, total: 4602).
[gmic]-0./ Input text-data file 'gmic_stdlib.gmic'.
[gmic]-1./ Parse '#@cli' command(s) '*' and output in 'bashcompletion' mode.
[gmic]-0./ End G'MIC interpreter.
Bash completion script 'gmic_bashcompletion.sh' has been successfully generated in '../resources/'.
gosgood@bertha ~/git_repositories/gmic/src $ cd ../resources
gosgood@bertha ~/git_repositories/gmic/resources $ ls
CeCILL.rtf  CMakeLists.txt  gmic_bashcompletion.sh  gmic_cluts.gmz  gmic_dark_theme_notepadplus.xml  gmic_denoise_cnn.gmz  gmic_gimp2.10_win64.iss  gmic_update          samples
cmake       debian          gmic_buildpackage       gmic_commit     gmic_demos.cimgz                 gmic_ftp              gmicol.gmic              gmic_upload_filters
gosgood@bertha ~/git_repositories/gmic/resources $ . gmic_bashcompletion.sh
gosgood@bertha ~/git_repositories/gmic/resources $ gmic help r ^I ^I
Display all 110 possibilities? (y or n)
r                  rad2deg            remove             replace_inf        resize3din         reverse            rgb2hsv            rgb2srgb           rm                 rotation3d
r2din              raindrops          remove_copymark    replace_nan        resize3dout        reverse3d          rgb2hsv8           rgb2xyz            rmn                rotoidoscope
r2dout             rand               remove_duplicates  replace_naninf     resize3dx          rgb                rgb2int            rgb2xyz8           rodilius           round
r2dx               random3d           remove_empty       replace_seq        resize3dy          rgb2bayer          rgb2jzazbz         rgb2ycbcr          rol                roundify
r2dy               random_clut        remove_hotpixels   replace_str        resize3dz          rgb2cmy            rgb2lab            rgb2yiq            rolling_guidance   rows
r3d                random_pattern     remove_named       reset              resize_as_image    rgb2cmyk           rgb2lab8           rgb2yiq8           ror                rprogress
r3din              rbf                remove_opacity     resize             resize_mn          rgb2hcy            rgb2lch            rgb2yuv            rorschach          rr2d
r3dout             rectangle          remove_pixels      resize2din         resize_pow2        rgb2hsi            rgb2lch8           rgb2yuv8           rotate             run
r3dx               red_eye            repeat             resize2dout        resize_ratio2d     rgb2hsi8           rgb2luv            rgba               rotate3d           rv
r3dy               register_nonrigid  replace            resize2dx          retinex            rgb2hsl            rgb2oklab          ri                 rotate_tileable    rv3d
r3dz               register_rigid     replace_color      resize2dy          return             rgb2hsl8           rgb2ryb            ripple             rotate_tiles       ryb2rgb

Hope this helps

1 Like

Yes, and you need gmic to make it run properly :slight_smile:

This file is actually auto-generated by the integrated G’MiC parser (the same that displays the help on terminal and generates the web pages).

@grosgood That trick didn’t work here. Still looking on how I can do that with Windows CMD.

This is targeted for bash users. I’m not even sure you can do something similar with Windows CMD.

EDIT: I would recommend installing MSYS2 to get a real bash-compliant terminal for playing with the gmic tool.

Auto-completion is a Bourne Again Shell (aka bash) facility, native to Linux environments. See How to create a Bash Completion Script. A native Windows cmd.exe session won’t know what to do with this script because the facility ultimately needs complete, a bash shell built-in command. However, there is the Linux Subsystem for Windows. This article suggests a way for Windows users to have a bash shell: How to install Bash on Windows 11. You would also install gmic separately in your Windows Linux subsystem.

Ah! Why didn’t I think of this? Thanks!
I think i’ll write a little script to download and compile all of this every now and then (before i forget :slight_smile: ).

Does that mean i have to build G’MiC first (which seems logical)?

PS: see? I wrote G’MiC properly this time!
PS2: Maybe next time i’ll open a new thread instead of hijacking the changelog :sweat_smile:

This discussion has a new home now. :slight_smile:

2 Likes

Thanks, I didn’t expect so many answers :slight_smile: