Skip to content

reliably expand fuzzily selected snippets in Linux

Notifications You must be signed in to change notification settings

Konfekt/snippy.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

In the quest for an analogue on Linux of Autohotkey that exclusively runs on Microsoft Windows, neither autokey nor espanso proved as reliable.

Use

Instead, this little shell script snippy.sh that depends on

expands (by typing it out via xdotool) a fuzzily selected string from a popup menu (provided by rofi).

Each such string, say LGTM, is stored as the name of a file ~/.snippy/LGTM inside ~/.snippy that expands to the content of the file. For example, if ~/.snippy/LGTM reads Looks good to me!, then fuzzily selecting LGTM writes out Looks good to me!.

This works quite universally, that is, in every text box, editor, ... because xdotool simulates key presses.

To call it by a global key binding, a daemon such as xbindkeys (or sxhkd) is needed.

Installation

  1. Save this script, say to ~/bin/snippy.sh by

    mkdir --parents ~/bin &&
    curl -fLo https://raw.githubusercontent.com/Konfekt/snippy.sh/master/snippy.sh ~/bin/snippy.sh
  2. mark it executable by chmod a+x ~/bin/snippy.sh,

To launch snippy.sh by a global keyboard shortcut, say by pressing, at the same time, the Microsoft Windows key and S:

  1. install xdotool, rofi and, say, Xbindkeys (or Sxhkd), (for example, on openSUSE by sudo zypper install xbindkeys respectively sudo zypper install xdotool rofi sxhkd)

  2. add to ~/.xbindkeysrc a key binding that launches snippy.sh, say

    "$HOME/bin/snippy.sh"
        Mod4 + s
  3. start xbindkeys.

To start xbindkeys automatically at login, say on a KDE desktop environment, put a file xbindkeys.sh reading

#! /bin/sh
xbindkeys

into ~/.config/autostart-scripts/.

Credits

This script is based on snippy and passmenu; all credit shall be theirs and their licenses apply.

About

reliably expand fuzzily selected snippets in Linux

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages