Sudo Rambles
  • Home
  • Privacy Policy
  • About
  • Contact
Categories
  • cheat-sheets (2)
  • guides (11)
  • news (1)
  • ramblings (4)
  • tutorials (10)
  • Uncategorized (9)
Sudo Rambles
Sudo Rambles
  • Home
  • Privacy Policy
  • About
  • Contact
  • guides
  • ramblings

Alias a command – Ubuntu

  • 14th August 2019

Intro

This will be a short-and-sweet one. What is an alias you ask? It’s a shorthand version (macro) pretty much. Welp, let’s use it for something. Essentially, let’s goof off with it, for starters. Instead of using sudo, let’s go with something more … well fun.

Here’s the obligatory screenshot:

“pls” as an alias for sudo

Guide

Step 1.

Open ~/.bashrc with your favourite text editor (nano, vim …)

Step 2.

At the very bottom of the file, add your alias in the following format:

alias='command'

Here’s mine:

The current file setup

Step 3.

Save the file and load the script, by running the following command:

source ~/.bashrc

And you’re done. I’m using this as a goof, but you can map seriously heafty commands to an alias, and you can make your life easier.

A more usable example

PHPCS is an amazing tool for checking code quality, if you’ve never heard of it check it out here: https://github.com/squizlabs/PHP_CodeSniffer

The command to check for PSR compliance is lengthy, and I really don’t want to type it out every time, so let’s make an alias of it.

Base command:

 php phpcs.phar
      -p
      -n
      -d memory_limit=320M
      --standard="${STANDARD}"
      --extensions=php,phtml
      --runtime-set testVersion "${PHP_VER}" app

Mapped as an alias (inside the bashrc file:

Mapped the compliance check in the file

The above line is callable with psrcompliance from the terminal

Great stuff, have fun!

Home

Previous Article
  • guides
  • tutorials

PHPStorm automatic code re-format

  • 17th June 2019
View Post
Next Article
  • Uncategorized

Routing all network traffic through TOR

  • 9th November 2019
View Post
Sudo Rambles
  • LinkedIn
  • Twitter
A programmer's blog

Input your search keywords and press Enter.

GDPR notice
This website uses cookies to cache data localy. This means the site loads faster on later visits. Please, indicate if you're ok with this.Yep, that's fineNot my cup of tea Read More
Cookie Policy

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. This category only includes cookies that ensures basic functionalities and security features of the website. These cookies do not store any personal information.
Non-necessary
Any cookies that may not be particularly necessary for the website to function and is used specifically to collect user personal data via analytics, ads, other embedded contents are termed as non-necessary cookies. It is mandatory to procure user consent prior to running these cookies on your website.
SAVE & ACCEPT