0

I am using Bash in Linux, inside Termius on a smartphone.

I would like to make reaching for particular symbols as fast as possible, by customizing bash to interpret certain character sequences as those symbols.

On a smartphone, maximum speed is using your thumbs on the primary (alphabet) keyboard and not requiring 1-2 additional keypresses to toggle the keyboard to display available symbols.

It appears that aliases are like macros in that they get substituted before any commands and run (except inside strings), so this works:

$ alias zz=#

$ zz a comment

but not this:

$ echo A hash: zz
A hash: zz
$

I could in addition do:

zz=#

echo $zz

But it requires 2 additional key presses to add in that dollar sign.

I may be able to install custom smartphone keyboards, but I want to focus on a more generalizable solution where I can customize Bash.

Is there any feature where Bash will immediately substitute a sequence of characters in the input line?

Before you’ve even hit enter, if you type “ii”, you actually see # in the command line:

user types one i

$ i

user types second i

$ #

Bash immediately substituted the code.

Is this possible? If not, what’s a good workaround?

  • I don't think this is a good approach. Even if you found the perfect answer to your question, that would mean your keyboard would work differently in bash and in the programs bash could launch (like, say, dialog, ssh, mc, gpg, you name it). That'd be very counterintuitive, because while running a script you might not realize which parts are your character -substituting bash, and which are some other program. You deserve a consistent solution! – Marcus Müller Nov 06 '22 at 08:04
  • And that solution would be one of the programming-oriented Android keyboards. – Marcus Müller Nov 06 '22 at 08:05
  • zsh allows aliases to expand anywhere in a command. They call these "global aliases" – glenn jackman Nov 07 '22 at 14:07

0 Answers0