0

I want to create an alias for the nedit command but with the ability to add a .txt automatically to the passed argument. For example, when I would type n newfile --> it should execute --> nedit newfile.txt.

In other words, "n (file_name)" should automatically give me file_name.txt

Currently, I'm using alias n "nedit".

Please let me know if this can be done within the CSH shell.

closed as off-topic by muru, Kusalananda, Ipor Sircer, Jeff Schaller, G-Man Feb 15 '18 at 23:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question has been posted on multiple sites. Cross-posting is strongly discouraged; see the help center and community FAQ for more information." – muru, Kusalananda, Ipor Sircer, Jeff Schaller, G-Man

4

Aliases in the csh shell are slightly more advanced than aliases in sh-like shells.

To create an alias n that calls nedit with the given filename and that adds a .txt extension to that filename, you may do something like

alias n nedit \!:1.txt

!:1 will be replaced by the first command line argument after the alias name when invoking the alias. The ! has to be escaped as \! to not trigger history expansion.

For more information about csh and tcsh aliases, see "Writing Aliases in csh and tcsh" (a site external to U&L).

  • yes!!! yeah your suggestion is working pretty fine. for the above alias requirement. i mean let say i entered "nedit newfile.txt" then automatically it should add & to command and execute nedit newfile.txt &" – Ashok Kumar Mishra Feb 15 '18 at 10:24
  • if i have to add "&" to all commands automatically then how to do so? – Ashok Kumar Mishra Feb 15 '18 at 10:25
  • 1
    @AshokKumarMishra I don't think you would actually want to add & to the end of all commands, do you? This is furthermore a separate question. – Kusalananda Feb 15 '18 at 10:26
  • in my usage in almost every where – Ashok Kumar Mishra Feb 15 '18 at 10:27
  • 1
    @AshokKumarMishra Please ask a separate question about this. It does not seem related to this question here. When you ask the new question, please also clarify it with examples as I'm not sure I fully understand it. – Kusalananda Feb 15 '18 at 10:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.