[HN Gopher] Show HN: Espanso: detect a typed keyword and replace...
___________________________________________________________________
Show HN: Espanso: detect a typed keyword and replace it while
you're typing
Author : HipstaJules
Score : 109 points
Date : 2021-02-03 09:34 UTC (13 hours ago)
(HTM) web link (espanso.org)
(TXT) w3m dump (espanso.org)
| jhunter1016 wrote:
| I used TextExpander every day at an old job and it saved me a ton
| of time. This looks really nice. Congrats!
| federicoterzi wrote:
| Thanks! TextExpander is a great product indeed, but it did not
| work on Linux and that's one of the reasons why I originally
| created espanso :)
| offtop5 wrote:
| Looks really cool, but isn't this literally a key logger.
|
| I prefer this to be built in to maybe vs code, at least then I
| won't have to worry about accidentally capturing my passwords
| jerrygoyal wrote:
| I usually use emmet feature (snippets) of vscode but then I
| also use other editors like np++, sublime or simple notepad for
| quick editing and lack the ability of snippets. Using a system
| wide textexpander makes sense. this is also the reason i dont
| use any chrome extension for color picking or taking
| screenshots. always better to use systemwide utilities.
| federicoterzi wrote:
| Good point, I've wrote a short section to detail the security
| aspects: https://github.com/federico-
| terzi/espanso/blob/master/SECURI...
|
| TLDR: It's not a keylogger, because it doesn't log anything :)
|
| Moreover, on macOS the detection mechanism is automatically
| disabled on password fields
| federicoterzi wrote:
| Also, the biggest benefit of this approach compared to a
| VSCode-only snippet, is that it works on any application and
| also between different operating systems, which makes it
| easier to collaborate and reuse them :)
| offtop5 wrote:
| Thanks for the response, but unless I take the time to
| literally go to your entire repo and make sure you aren't
| doing anything weird, I'm not installing this thing.
| federicoterzi wrote:
| That's absolutely ok! I'm also very open to feedback if you
| have any :)
| ivanbakel wrote:
| If you're in a position to use this program[0], you're
| already taking the same risk by running most other programs
| on your machine - they also have access to your keypresses.
|
| [0]: The only real reason you wouldn't be is if you're on a
| non-X Linux desktop. Wayland prevents this kind of program
| by design.
| federicoterzi wrote:
| Fun fact, Wayland support is the most requested feature
| [1] and I think it's possible, although we will need to
| go deeper in the stack and exploit EVDEV
|
| [1]: https://github.com/federico-terzi/espanso/issues/287
| ivanbakel wrote:
| A nice technical writeup! The daemon approach sounds
| particularly promising. Have you also thought about a
| Wayland protocol extension? espanso is not the only
| program that will want total keyboard access, and it's
| one of the last big obstacles for a lot of X11 users.
| federicoterzi wrote:
| Thanks!
|
| > Have you also thought about a Wayland protocol
| extension?
|
| I honestly didn't think about that! That might be an
| option, perhaps when espanso becomes more well-known in
| the community. Before that, it's unlikely that any change
| I suggest will make its way into the specification :)
| ornornor wrote:
| The world is a little bit bigger than VSCode. Believe it or not
| some of us don't even use VSCode.
|
| This is meant to be a replacement to AHK (which is Windows
| only), not a text editor snippet expander.
| dafman wrote:
| I've been using Espanso for about a month and it's made some
| tasks in my daily life so much easier. I regularly have to use
| template text, and instead of having to copy-paste it every time
| I've just set it to a snippet and it ends up saving me quite a
| lot of time. I've also taken to using it for URLs, as in some
| repsects its easier than having something bookmarked.
|
| Definitely one of those tools that make me wonder how I got by
| without it
| federicoterzi wrote:
| Thank you very much for the kind words! I appreciate it :)
| moltar wrote:
| First I thought "oh yet another expander". Then I saw forms! I
| wanted this for ages. Take my money! :D
| federicoterzi wrote:
| Thanks, and by the way, espanso is completely free and open-
| source! Though if you like it, a donation is always welcomed :)
| ivanbakel wrote:
| Last (big) discussion:
| https://news.ycombinator.com/item?id=22191794
| felixr wrote:
| I have a simple custom solution that works well for me. Snippets
| are just files in a directory. The filename is the snippet name.
| If the file is executable, it uses whatever is returned from
| running it. You can use zenity [0] to create forms or run
| rofi/dmenu to select "arguments" in those scripts.
|
| It uses `rofi` and `xdotool`: #!/bin/bash
| SNIPPET_DIR="${HOME}/.config/snipex" DMENU="rofi -dmenu -b
| -p Snippet:" XSEL="/usr/bin/xsel --clipboard --input"
| SNIPPET=$(ls -1 "${SNIPPET_DIR}" | ${DMENU})
| FILE="${SNIPPET_DIR}/${SNIPPET}" STRIP_NEWLINE="head
| -c -1" if [ -x "${FILE}" ]; then # snippet
| is executable -> run it and copy the result ${FILE} |
| ${STRIP_NEWLINE} | ${XSEL} elif [ -f "${FILE}" ]; then
| # copy the contents of the file ${STRIP_NEWLINE} ${FILE}
| | ${XSEL} else # clean clipboard echo "" |
| ${XSEL} fi xdotool key --clearmodifiers
| "Shift+Insert"
|
| edit: and I have an xbindkeys config to run this script when I
| press Meta+,
|
| [0]: https://help.gnome.org/users/zenity/stable/forms.html.en
| alpaca128 wrote:
| Interesting, I built a similar system for my Vim setup that I
| slowly adopted over time. I realised that semicolons are almost
| always followed by whitespace or newlines in normal use, so I
| started defining a whole range of shortcuts with `;` as a prefix.
| As the key is directly on the homerow it's also quick and easy to
| use.
|
| For example I have `;out` defined to expand to the correct stdout
| print function depending on the programming language used in that
| file.
|
| Espanso looks like it's a great way to expand the same concept to
| the whole system, albeit (I'm guessing) without the contextual
| info a text editor can provide.
| federicoterzi wrote:
| > Espanso looks like it's a great way to expand the same
| concept to the whole system, albeit (I'm guessing) without the
| contextual info a text editor can provide.
|
| That's right, out of the box espanso does not have any access
| to the contextual information, but with some "script
| gymnastics" [1] you can do plenty of interesting things :)
|
| [1]: https://espanso.org/docs/matches/#shell-extension
| temp0826 wrote:
| I've been looking for a system-level "cloud" -> "butt". Thanks!
| federicoterzi wrote:
| You're welcome! :) You might also enjoy the dad-jokes package:
| https://hub.espanso.org/packages/dadjoke/
| gerdesj wrote:
| Love it! It turns out espanso is in the AUR for Arch.
|
| I've just filled kate with dadjokes which isn't as sick as it
| sounds!
| federicoterzi wrote:
| Thanks! The AUR package is all thanks to our wonderful
| maintainer Scrumplex [1].
|
| [1]: https://scrumplex.net/
| magnio wrote:
| I used Espanso a while back on my Win 10 machine. It was nice,
| but I got noticeable lag compared to the smooth replacing of
| AutoHotKey (AHK also uses less resources).
|
| I might switch to Espanso in the future though, given that AHK is
| not available on Linux.
| federicoterzi wrote:
| I'm sorry you experienced this problem! How many snippets were
| you using? AHK is indeed a wonderful tool, and because it only
| supports Windows, it can apply some optimizations that are not
| available on other platforms. I'm currently rewriting the core,
| so things might get a bit faster in the future :)
| magnio wrote:
| I don't use many snippets, probably less than a hundred.
|
| Just tried it again. Not as slow as I remember, the syntax is
| also cleaner than AHK. Switching to it now :)
| federicoterzi wrote:
| Thanks! If you have any feedback or experience any problem,
| feel free to open an issue on GitHub :)
| snet0 wrote:
| As someone with quite a few AHK hotstrings, and who does almost
| all of their day-to-day in Windows, what's the selling point for
| this software vs AHK? Looks like a great and useful piece of
| software, but is there a reason to prefer this in cases where AHK
| is viable?
| ohnoesoes wrote:
| idk man it feels like few seconds look at the website of both
| will show the differences quite easily.
| federicoterzi wrote:
| Hey, the main difference is mostly its cross-platform support,
| but also forms [1] and (probably) scripts [2]
|
| [1]: https://espanso.org/docs/forms/ [2]:
| https://espanso.org/docs/matches/#shell-extension
| bryanrasmussen wrote:
| when it says: Works with almost any program - what programs is it
| not working with, and are they OS specific? From what I know of
| text expansion on Windows I would expect every program on Windows
| works and it is Mac and Linux that gives the problems?
| federicoterzi wrote:
| (Author here)
|
| As long as the program accepts keyboard input or clipboard
| pasting, espanso should work correctly. There are some programs
| that behave a little bit differently (such as Thunderbird on
| Linux), that require a couple of configuration changes to work
| as expected (for example, slowing down the injections if the
| program is slow to process input).
|
| Happy to answer any other question :)
| RicoElectrico wrote:
| > for example, slowing down the injections if the program is
| slow to process input
|
| It's 2021 and some people still don't separate UI into its
| own non-blocked thread.
|
| E.g. When crunching a big dataset in QGIS (on Win10), every
| digit I type into "Classes" box [1] blocks everything and I
| have to wait.
|
| [1] https://i.stack.imgur.com/oddT7.jpg
| federicoterzi wrote:
| Yep, that often happens! I sometimes experience this
| behavior on Google Docs, especially on slower machines
| userbinator wrote:
| Given the... average quality of software in 2021, I'm not
| sure you'd rather have intermittent crashes and freezes
| instead, because multithreading is notoriously tricky to
| get right --- and I'm saying this as someone who has worked
| in software for several decades.
| Kaze404 wrote:
| I thought about making something like this once. Seems incredibly
| useful, thank you!
| federicoterzi wrote:
| Thanks! Glad you liked it :)
| noja wrote:
| Cool. Any thoughts on how it compares to Clavier?
| https://gryder.org/software/clavier-plus/?lang=en
| federicoterzi wrote:
| Thanks! It's the first time I get to see Clavier so I'm not
| very prepared, but some differences could be:
|
| 1. Espanso is cross-platform, so you create your config once
| and then run it on all your machines 2. Clavier comes with a
| GUI, but espanso does not (yet) 3. Espanso is highly flexible
| thanks to scripts [1] and forms [2]
|
| 1: https://espanso.org/docs/matches/#shell-extension 2:
| https://espanso.org/docs/forms/
| tyingq wrote:
| Ahh, so it has a built-in prank mode. Don't leave your
| workstation unlocked :) show_icon: false
| show_notifications: false
| swader999 wrote:
| Perfect. April fools day isn't that far off folks.
| federicoterzi wrote:
| Never thought about that! That could be funny indeed :)
| justindirose wrote:
| I used to use TextExpander, but their app started to feel
| unpolished and was a bit expensive for my tastes. I've been using
| Espanso now for the most of the last year and I've been enjoying
| it. I even made a video about it [0].
|
| My favorite "feature" is the fact that it works so easily cross-
| platform.
|
| [0]: https://www.youtube.com/watch?v=RjXohQcuZyk
| federicoterzi wrote:
| Thank you! I'm glad you liked the project :)
| federicoterzi wrote:
| (Author here)
|
| Feel free to ask any question, I'll be happy to answer them :)
| shaicoleman wrote:
| It doesn't detect backspace with non-backspace keys under
| Linux.
|
| I'm using the Colemak keyboard layout, and Caps Lock is mapped
| to Backspace.
| federicoterzi wrote:
| Thanks for reporting this issue! I'm currently rewriting the
| detection mechanism core, so hopefully this problem will be
| solved in the next version :)
| Ciantic wrote:
| It's very nice that this is done with Rust, because I'd love to
| get rid of AutoHotkey in Windows (which also trivally support
| this kind of expansions). Do you plan to release individual
| components as crates?
|
| I don't see myself using single program to do just expansions,
| but instead building my own program with Rust that has all sort
| of shortcuts like in AutoHotkey. I could use your expansion
| code as crate instead.
| Tade0 wrote:
| For keylogging and mouse/keyboard automation you can use
| this:
|
| https://crates.io/crates/enigo
|
| And this:
|
| https://crates.io/crates/device_query/0.2.0
|
| respectively.
| federicoterzi wrote:
| Hey, It's unlikely that espanso will become a library anytime
| soon, but I'm currently refactoring the core into separate
| crates to follow a more modular "workspace" approach. So if
| you want to write your own standalone program, you could just
| pick the modules you need!
|
| Started the refactor a few days ago so it's still in the
| early stage, but it's happening here:
| https://github.com/federico-terzi/espanso/tree/dev-1.x
| flotothemoon wrote:
| First, this looks awesome, will be giving this a try. Is there
| a way to pass (inline) arguments to the expansion? Or would I
| use a form for that?
|
| e.g. ":member(test)" => "private test;"
| federicoterzi wrote:
| Thanks! I'm currently working on a way to make this possible,
| but for now you will have to stick with forms :) (or passive
| mode [1], but I'd advice against that as it's going away in
| the next version).
|
| [1]: https://espanso.org/docs/passive-mode/
| Kaze404 wrote:
| I seem to have found a bug. When I use the default match
| ":espanso" on my terminal (Kitty) it gets expanded to "hi
| there1", while I expect "Hi there!". Seems to work fine on
| Firefox.
|
| Edit: Seems like it's an issue with shifted characters? When I
| type any trigger and erase, for example ":espanso", I expect
| the first character to be a colon (:) but instead I get a semi-
| colon (;). Weird.
| federicoterzi wrote:
| Thanks for reporting this issue! I'm working on a patch that
| should solve this problem. In the meanwhile, can you try
| adding:
|
| backend: Clipboard
|
| on your default.yml file and see if that helps?
| shaicoleman wrote:
| Same issue with shift not working under Kitty. (e.g. :DATE
| trigger produces )@?)#?@)@! )
|
| backend: Clipboard works intermittently for me
| Kaze404 wrote:
| Works perfectly now, thank you :)
| tnorthcutt wrote:
| Espanso looks pretty cool! I'm curious if you can share
| compelling reasons to switch from e.g. Alfred's snippets
| functionality (on macOS)?
|
| I've used aText for a long time, then semi-recently moved most
| things to Alfred, but I'm curious about Espanso :)
| federicoterzi wrote:
| Thanks! First things that come to my mind: 1. Espanso is free
| and open-source 2. If you use espanso and then move to Linux
| or Windows, the transition is flawless 3. It support Forms
| [1] and it can be extended in many ways [2] 4. You can easily
| collaborate with others and share snippets on the Hub:
| https://hub.espanso.org/
|
| Cons: There is no GUI yet, but we are working on it
|
| [1]: https://espanso.org/docs/forms/ [2]:
| https://espanso.org/docs/matches/
| tnorthcutt wrote:
| Thanks for the replies!
|
| One more question if you're up for it: does Espanso suffer
| from having secure input disabled?
|
| I frequently see this with both aText and Alfred: "Secure
| input is enabled (by loginwindow)" (aText) & "loginwindow
| seems to be preventing text expansion by locking secure
| entry" (Alfred)... with no indication as to how to rectify
| the situation.
| tnorthcutt wrote:
| Ah nevermind, I see this when I run `espanso start`:
|
| "WARNING: An application is currently using SecureInput
| and might prevent espanso from working correctly."
|
| For anyone else who ends up here with the same problem:
| this blog post was helpful as it suggested that locking &
| unlocking my system might remove the lock on secureinput
| created by loginwindow: https://rakhesh.com/mac/macos-
| find-app-using-secure-input/
| federicoterzi wrote:
| Yes, unfortunately there is not much we can do about
| that, given that macOS does not give us much information
| :)
| akvadrako wrote:
| How does this integrate on Linux? I took a minute and couldn't
| find that information on the website.
| federicoterzi wrote:
| Espanso currently supports X11-based linux systems through
| the X Record Extension [1] and libxdo [2]
|
| That said, I'm currently working on another engine based on
| evdev that could be able to support also Wayland systems.
|
| For the linux install see also:
| https://espanso.org/install/linux/
|
| [1]: https://www.x.org/releases/X11R7.6/doc/libXtst/recordlib
| .htm... [2]: https://github.com/jordansissel/xdotool
| eterps wrote:
| Awesome, would love to give it a try as a Wayland user.
| federicoterzi wrote:
| Thanks! your best bet is to activate notification on the
| issue I linked before :) I'm currently working on it, the
| detection part is almost done, I'll need to figure out
| the best way to inject the text after detecting a match
| dlkmp wrote:
| I use QMK macros/ tap dances for the same thing as a 100%
| platfrom independent solution (albeit being also a 100% hardware
| dependent solution).
| BiteCode_dev wrote:
| Bit of a plug, but if you crave for that, and more, you can use
| AutoKey on Linux (not AutoHotKey which is Windows only):
| https://github.com/autokey/autokey
|
| It will let you bind custom Python scripts to any mouse/keyboard
| sequence, including words on the fly. It can trigger word
| replacements just like Espanso (I use it to fill in emails,
| dates, addresses, timestamps et phone numbers), and of course,
| Python being Python, it lets you do a lot more.
|
| The UI is probably not as good as Espanso's, and it may be harder
| to use (you need to script). On the other hand, it provides an
| API for prompting you with UI to select dates, files, input,
| etc., has timers and the whole Python 3 stdlib.
|
| Some nice stuff I do with it:
|
| - typing $email/$ phone present me with a list of email
| addresses/phone num (I have a lot of them) to insert one.
| Prevents typo. By pass web form limitations.
|
| - $now and $date does something similar with dates (listing of
| various formats for the current date and a calendar). Very handy
| for documents and file name. Most of them don't have automated
| fields set up.
|
| - $paste paste the clip board content, by passing any UI
| preventing me to do so, and screen/tmux limitations.
|
| - I'm a heavy dynalist users (dynalist.io/) I love this software,
| but it lacks a lot of features, which are easy to add with
| AutoKey: just make a macro that inputs a serie of actions.
| federicoterzi wrote:
| Hey, AutoKey is awesome indeed! I've used it myself for a while
| before developing espanso. In fact, I went through the code-
| base multiple times to understand how it could be so fast. I
| learned plenty of things about how the X server works thanks to
| you :)
| BiteCode_dev wrote:
| Thanks for making your tool opens ource.
|
| Do you plan to add scripting capabilities to Espanso or do
| you prefer to focus on the current use case ?
| federicoterzi wrote:
| You're welcome! Espanso on Linux wouldn't be possible
| without other open-source projects, so that's the least I
| can do to give something back to the community :)
|
| > Do you plan to add scripting capabilities to Espanso or
| do you prefer to focus on the current use case ?
|
| We might add a "macro" feature to add delays and combine
| multiple keypresses, but I don't see espanso becoming a
| general "automation" tool. There are already plenty of
| great options for that (including AutoKey)!
| jijji wrote:
| This is pretty awesome....For windows and DOS there has always
| been a program called Shorthand and PRD+, but nothing has existed
| for Linux.
| federicoterzi wrote:
| Thanks! Actually, there is AutoKey for linux and it works
| pretty well, though I personally started espanso because I
| often use different operating systems, and none of the existing
| tools was cross-platform :)
___________________________________________________________________
(page generated 2021-02-03 23:02 UTC)