0

I have following alias in my .cshrc

alias fe-fat  "source fat  /prj/work"  
alias fe-fat1 "source fat1 /prj/work"

I wanted to know if we can set some variable for fat/fat1 and club the above 2 aliases into a single alias somewhat like the below, so that whenever I type fe-<variable> in the Unix terminal the above alias should work

alias fe-<variable> "source <variable> /prj/work" 
Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
James bond
  • 459
  • 1
  • 4
  • 13

2 Answers2

0

No, I don't think that's possible with alias.

What are you actually trying to achieve?

It'd be simple enough to write a bash script that launches other commands based on a parameter (so you'd type fe <variable> instead of fe-<variable>).

It's not really worth it with only 2 commands but you could also provide a custom auto-complete script: See Line completion with custom commands

Community
  • 1
  • 1
John Carter
  • 53,924
  • 26
  • 111
  • 144
0

Any particular reason you wouldn't just alias it to something that takes a parameter?

alias fe "source \!:1 /prj/work"

fe fat   #=> source fat  /prj/work
fe fat1  #=> source fat1 /prj/work
brymck
  • 7,555
  • 28
  • 31
  • Hi Bryan,Thanks for the solution it worked well Had one more query to the above solution for example i have word's quiet big say like "fat_abcd" etc,So typing this long word "fe fat_abcd" So is there a way we can set an alias for "fat_abcd" like "fab" and then use ur above workaround "fe fab" I I tired aliasing but it didnt work so is there a way we can do that – James bond Jul 15 '12 at 13:22
  • @Jamesbond I don't believe so; the best idea may just be to give that its own alias like `alias feb "source fat_abcd /prj/work"`. If you want that kind of functionality I'd use something like zsh which offers [global aliases](http://www.refining-linux.org/archives/53/ZSH-Gem-19-Global-aliases/). – brymck Jul 16 '12 at 03:41