HN.zip

Show HN: Empty Enter Expander – Type less in the terminal with this tool

When you have a lot of aliases it can be difficult to remember how was the one you need named especially if you do not use it very often. You can also have files stored in a bin folder and look there to find the name. Another trick is to prepend your commands with a comma then type the comma and hit the Tab key to see only your own commands. There is an article about it somewhere on the Internet.I needed something lightweight to always show me the available commands. Something to run with a few keystrokes. Something that stores commands in files and folder structures.The idea was born at the time of using Linux Debian with the dwm (dynamic window manager). The first version was implemented in bash and it could do three things: start an application, expand text from a template and do a predefined automation on the selected application.It was launched by a keyboard shortcut and opened the list of commands in a new terminal window. The commands were stored in nested folders and it was able to switch between the three modes (launcher, expander, automator). It also required only few keystrokes to do the desired action.For instance, I was in the terminal and hit Ctrl+P. It opened a new terminal and listed applications to launch. I hit the Space to switch to the expander mode. Then I hit the g to enter the Git folder and s for the status. The result was that it put the git status to the terminal I was in before. This expander could be used in any application. It could insert the email template into the browser.Then I migrated to macOS and really missed that tool. So I quickly wrote a zsh vesrion that consists only the expander mode and supports only the terminal. It is activated by hitting Enter on empty command and then it inserts the desired command right into the prompt. For example, when you hit Enter, g and s you will get the git status command to the prompt and you can then execute it with Enter. Of course, those commands and keys are defined by you. There are various and lenghty commands that I use on a daily basis like this and it saves a lot of typing.The tool is called Empty Enter Expander. It is implemented for the zsh as of now. Please check it out at https://github.com/waszabi/empty-enter-expander and let me know what you like or dislike about it.

30 points by waszabi - 10 comments

10 Comments

jinnko [3 hidden]5 mins ago
I've been using https://github.com/denisidoro/navi for this kind of scenario.
gitroom [3 hidden]5 mins ago
Tbh having tons of aliases always messes me up, half the time I forget them and just end up typing full commands anyway lol
sudahtigabulan [3 hidden]5 mins ago
Aliases as a feature are meant to save you typing in the first place.

The more you use aliases, the more you save in typing, over time.

If you can't remember a particular alias, that means you have a use for it very rarely (spaced repetition and all that), and the benefit of having it around is very low anyway.

I generally try to prune my bashrc from aliases that turned out not as useful as I thought. I have about 50 atm, and don't feel the need for a helper tool.

Maybe if one's aliases skew towards a particular pattern this tool could be useful, I don't know.

flexagoon [3 hidden]5 mins ago
Fish shell has abbreviations, which expand into the full command, support regex patterns, and can expand arguments to a different command

https://fishshell.com/docs/current/cmds/abbr.html#examples

tomoviktor [3 hidden]5 mins ago
> When you have a lot of aliases it can be difficult to remember how was the one you need named especially if you do not use it very often.

I use tmux and I use this small keybind to launch a place where I can search my aliases: bind-key a run-shell 'tmux neww -n "aliases" "source ~/.zshrc && alias | fzf"'

I like this workflow because it's quick. I always thought that if I want to shorten something I will just make and learn and alias for it and that's it.

piranha [3 hidden]5 mins ago
That's a fantastic idea! I've made it a bit simpler for myself — basically just `source file`, so that I don't need to press enter to execute it, but also added one cute detail in the loop:

    if [[ -f "$target/.exec" ]]; then
        zsh "$target/.exec"
    fi
mrlambchop [3 hidden]5 mins ago
I don't know about anyone else, but when transitioning back to a shell, I HAVE to hit a bunch of enters on any prompt to clear the last output away a few lines before I can summon up the powers to enter a new command - blow away the cobwebs and all that. I love the empty enter command line :)
laktak [3 hidden]5 mins ago
I think there are a lot of different takes on this. Mine uses playbooks, if you are interested https://github.com/laktak/tome
pseudo_meta [3 hidden]5 mins ago
Is it possible to trigger the expander differently?

I already have zsh-magic-dashboard running on empty enter.

waszabi [3 hidden]5 mins ago
Yes, when you configure the expander based on the readme change the ^M (enter key) on the following line to any key you wish:

bindkey "^M" empty-enter-expander

^E represents Ctrl + E M-e represents Alt + E ...