Skip to content
Francesco edited this page Sep 24, 2017 · 23 revisions

What is an alias?

An alias allows you to make new shortcuts and synonyms for commonly used commands.

Why should I be interested in this?

For example, if you usually try to ping google.com in order to check your internet connection speed, it is really bothering to type every single time this command:

ping -c 10 google.com

To avoid this you can set up the alias pg that will tell t-ui to launch the above long command for you.

pg=ping -c 10 google.com

Now, anytime you want to check your internet speed you can simply type "pg".

Nice! How do I create one?

There are two ways:

  • using the t-ui command "alias"
  • editing the file alias.txt

1. Using the command

You can use the command "alias -add" to append a new alias to your alias.txt file. It's simple and fast, and you won't need to bother looking for the file, saving, checking syntax, etc.

Be aware that this method has some limitations:

  • you won't be able to create a "no named alias" (an alias which has an empty name, that will be triggered when you hit enter and the input field is empty)
  • you won't be able to create an alias whose name contains one or more spaces

The syntax is the following:
alias -add [aliasName] [alias value]

For example:
alias -add news search -g news

2. Editing the text file

Open the text file using: alias -file

Then, append this line to that file:
alias name=alias value

For example:
j=call John Foo

You can also define a no-named alias by adding this line:
=alias value
This is pretty useful when you don't want to waste time for an emergency, or something similar.

For example:
=call 911

Parameterized aliases

Have a look at alias_param_marker and alias_param_separator (behavior.xml).

To create a parameterized alias, use the usual command
alias -add
but insert your marker where you want to place a param.

For example, if your alias_param_marker is "%" (default)
alias -add myAlias echo Hey %, this is a %!

To use this alias, you will need to type the name of your alias, plus your params separated by your alias_param_separator ("," by default).
myAlias user,param

Output:
Hey user, this is a param!

Nice parameterized aliases

One of my favourite aliases is this one:
voc=search -u http://learnersdictionary.com/definition/%

This easily let's me look for a word in an English vocabulary. I just need to type
voc word.


An other nice alias is this one:
bus=open /storage/emulated/0/Docs/Bus/Line-%.pdf

With this alias, I just need to type
bus number
to quickly open the corresponding bus plan.

Format alias content

Have a look at alias_content_format (behavior.xml).

Values:

  • %a -> alias name
  • %v -> alias value
  • %n -> newline

Example

%a --> [%v]

Output:
p --> [Play Store]

Clone this wiki locally