Skip to Content
Small, Sharp Software Tools
book

Small, Sharp Software Tools

by Brian P. Hogan
June 2019
Intermediate to advanced
328 pages
7h 27m
English
Pragmatic Bookshelf
Content preview from Small, Sharp Software Tools

Creating Shortcuts with Aliases and Functions

Bash lets you define your own versions of commands, either through aliases or functions.

Aliases let you create shortcuts for commands or override the default options for existing commands. You define them with the alias command, but it’s better to define them in your ~/.bashrc file. Let’s define some aliases.

Open your ~/.bashrc file in nano:

 $ ​​nano​​ ​​~/.bashrc

Let’s create an alias for ls -alh so you can avoid typing it out. Add this line to the end of the ~/.bashrc file to define an alias called ll:

 alias ll=​'ls -alh'

Save the file and exit the editor. Then source the file to apply the changes:

 $ ​​source​​ ​​~/.bashrc

Try running the ll alias:

 $ ​​ll
 total ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The VimL Primer

The VimL Primer

Benjamin Klein
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 9781680507003Errata Page