7 ms·
Show HN: Espanso: detect a typed keyword and replace it while you're typing
- ivanbakel 6y agoLast (big) discussion: https://news.ycombinator.com/item?id=22191794 https://news.ycombinator.com/item?id=22191794
- bryanrasmussen 6y agowhen 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 6y ago(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 6y ago> 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 https://i.stack.imgur.com/oddT7.jpg
- federicoterzi 6y agoYep, that often happens! I sometimes experience this behavior on Google Docs, especially on slower machines
- userbinator 6y agoGiven 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.
- federicoterzi 6y ago(Author here) Feel free to ask any question, I'll be happy to answer them :)
- akvadrako 6y agoHow does this integrate on Linux? I took a minute and couldn't find that information on the website.
- federicoterzi 6y agoEspanso 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/ https://espanso.org/install/linux/ [1]: https://www.x.org/releases/X11R7.6/doc/libXtst/recordlib.html https://www.x.org/releases/X11R7.6/doc/libXtst/recordlib.htm... [2]: https://github.com/jordansissel/xdotool https://github.com/jordansissel/xdotool
- eterps 6y agoAwesome, would love to give it a try as a Wayland user.
- federicoterzi 6y agoThanks! 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
- Ciantic 6y agoIt'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.
- jhunter1016 6y agoI used TextExpander every day at an old job and it saved me a ton of time. This looks really nice. Congrats!
- federicoterzi 6y agoThanks! 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 6y agoLooks 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
- federicoterzi 6y agoGood point, I've wrote a short section to detail the security aspects: https://github.com/federico-terzi/espanso/blob/master/SECURITY.md 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 6y agoAlso, 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 6y agoThanks 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 6y agoThat's absolutely ok! I'm also very open to feedback if you have any :)
- ivanbakel 6y agoIf 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.
- moltar 6y agoFirst I thought “oh yet another expander”. Then I saw forms! I wanted this for ages. Take my money! :D
- federicoterzi 6y agoThanks, and by the way, espanso is completely free and open-source! Though if you like it, a donation is always welcomed :)
- moltar 6y agoDone! Sponsored on GH :)
- alpaca128 6y agoInteresting, 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 6y ago> 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 https://espanso.org/docs/matches/#shell-extension
- noja 6y agoCool. Any thoughts on how it compares to Clavier? https://gryder.org/software/clavier-plus/?lang=en https://gryder.org/software/clavier-plus/?lang=en
- federicoterzi 6y agoThanks! 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 https://espanso.org/docs/matches/#shell-extension 2: https://espanso.org/docs/forms/ https://espanso.org/docs/forms/
- magnio 6y agoI 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 6y agoI'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 6y agoI 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 6y agoThanks! If you have any feedback or experience any problem, feel free to open an issue on GitHub :)
- dlkmp 6y agoI use QMK macros/ tap dances for the same thing as a 100% platfrom independent solution (albeit being also a 100% hardware dependent solution).
- temp0826 6y agoI’ve been looking for a system-level “cloud” -> “butt”. Thanks!
- federicoterzi 6y agoYou're welcome! :) You might also enjoy the dad-jokes package: https://hub.espanso.org/packages/dadjoke/ https://hub.espanso.org/packages/dadjoke/
- gerdesj 6y agoLove 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 6y agoThanks! The AUR package is all thanks to our wonderful maintainer Scrumplex [1]. [1]: https://scrumplex.net/ https://scrumplex.net/
- jijji 6y agoThis is pretty awesome....For windows and DOS there has always been a program called Shorthand and PRD+, but nothing has existed for Linux.
- federicoterzi 6y agoThanks! 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 :)
- dafman 6y agoI'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 6y agoThank you very much for the kind words! I appreciate it :)
- Kaze404 6y agoI thought about making something like this once. Seems incredibly useful, thank you!
- federicoterzi 6y agoThanks! Glad you liked it :)
- tyingq 6y agoAhh, so it has a built-in prank mode. Don't leave your workstation unlocked :) show_icon: false show_notifications: false
- swader999 6y agoPerfect. April fools day isn't that far off folks.
- federicoterzi 6y agoNever thought about that! That could be funny indeed :)
- justindirose 6y agoI 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 https://www.youtube.com/watch?v=RjXohQcuZyk
- federicoterzi 6y agoThank you! I'm glad you liked the project :)
- BiteCode_dev 6y agoBit 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 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 6y agoHey, 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 6y agoThanks 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 6y agoYou'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)!
- felixr 6y agoI 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 https://help.gnome.org/users/zenity/stable/forms.html.en
- snet0 6y agoAs 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 6y agoidk man it feels like few seconds look at the website of both will show the differences quite easily.
- federicoterzi 6y agoHey, the main difference is mostly its cross-platform support, but also forms [1] and (probably) scripts [2] [1]: https://espanso.org/docs/forms/ https://espanso.org/docs/forms/ [2]: https://espanso.org/docs/matches/#shell-extension https://espanso.org/docs/matches/#shell-extension
- ficklepickle 6y agoThis is really cool. I just made a keyboard shortcut tool and I wish I had known about this. Basically, I brought some Windows keyboard shortcuts to linux. Specifically, Alt + 0,N,N,N to type accented characters. For example, è is Alt + 0,2,3,2. Autokey was too slow, I ended up using a hacky OS keyboard shortcut + bash script approach. Ugly but it works! I should see if I can use espanso for this. https://github.com/jeremy21212121/linux_accent_hotkeys https://github.com/jeremy21212121/linux_accent_hotkeys https://jeremypoole.ca/posts/windows_keyboard_shortcuts_on_linux/ https://jeremypoole.ca/posts/windows_keyboard_shortcuts_on_l...