CoderX
CoderX

Reputation: 423

How to chain alias commands in cmder

I love using aliases on my ubuntu server for repeated commands as they're a huge timesaver and they're absolutely irreplaceable for me now.

I've been using cmder a lot recently on Windows as it is the best console replacement for windows that I know of. It is a wonderful piece of software and I have almost all the basic bash commands including aliases.

However, I cannot find a way to chain multiple alias commands. I've tried delving into doskey at this link Microsoft DOSKEY and the macros without any luck.

So, basically I want to create multiple aliases. For e.g.

    alias loginuser1='ssh -i ~/user1keyfile user1@$s'
    alias mynewcloudserver='901.801.701.601'

and want to be able to login by typing:

    loginuser1 mynewcloudserver
    loginuser5 mytestingcloudserver

I have currently tried this:

    loginuser1 mynewcloudserver 

which produces this error:

    ssh: Could not resolve hostname mynewcloudserver: no address associated with name

I get that this is because it is probably looking in my hosts file for mynewcloudserver and is unable to find an entry. I am able to login by doing this instead:

    loginuser1 901.801.701.601

which brings us to my problem. I am unable to call one alias from another alias

I know the above might not be the best way to create those aliases, but I just want to understand the logic and how to chain aliases together in cmder which will open up a host of possibilities pun intended.

If anyone can help me out, that would be great.

Upvotes: 2

Views: 2302

Answers (1)

brt
brt

Reputation: 153

The only option I've found is to create a myscript.sh file with the commands, and create an alias to call the file.

It may be helpful to include wait between commands if they need to finish before the next one runs.

The first time you run it, it may ask you which program to use. Choose Git for Windows.

Upvotes: 0

Related Questions