Add command line arguments to alias in Linux

Source: Internet
Author: User
Tags commit

The need for command-line arguments is useful when defining an alias. But the result of verifying the document is that the alias does not support passing command-line arguments at all. However, we can work around this problem by defining the function.

The code is as follows Copy Code

Alias test= ' Test () {echo $}; Test

[hadoop@nn069186 dev]$ Source ~/.BASHRC
[hadoop@nn069186 dev]$ test abc def GH
ABC def
[hadoop@nn069186 dev]$


The following example intercepts the alias defined by the self to facilitate the use of octopress to compose a Blog:

The code is as follows Copy Code
Alias Pn= ' new () {bundle EXEC rake new_post["$"}; New

Here, I pass the parameter to alias PN by defining the new () function. Just do it now:

The code is as follows Copy Code
PN ' Post title '

You can create a new post.

Another alias for submitting Source:

The code is as follows Copy Code

Alias Pc= ' commit () {git Add.; Git commit-m "$"; Git push origin source}; Commit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.