简体   繁体   English

如何在cmder中链接别名命令

[英]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. 我喜欢在ubuntu服务器上为重复的命令使用别名,因为它们节省了很多时间,并且现在对我来说绝对不可替代。

I've been using cmder a lot recently on Windows as it is the best console replacement for windows that I know of. 我最近在Windows上使用了cmder ,因为它是我所知道的Windows的最佳控制台替代品。 It is a wonderful piece of software and I have almost all the basic bash commands including aliases. 这是一个很棒的软件,我拥有几乎所有的基本bash命令,包括别名。

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. 我已经尝试过在此链接Microsoft DOSKEY和宏中没有任何运气的doskey。

So, basically I want to create multiple aliases. 因此,基本上我想创建多个别名。 For eg 例如

    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. 我知道这是因为它可能正在我的主机文件中查找mynewcloudserver ,但找不到条目。 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 . 我知道上述方法可能不是创建这些别名的最佳方法,但是我只是想了解逻辑以及如何在cmder中将别名链接在一起,这将为您提供许多可能的双关语

If anyone can help me out, that would be great. 如果有人可以帮助我,那就太好了。

The only option I've found is to create a myscript.sh file with the commands, and create an alias to call the file. 我发现的唯一选择是使用命令创建myscript.sh文件,并创建一个别名来调用该文件。

It may be helpful to include wait between commands if they need to finish before the next one runs. 如果命令需要在下一个命令运行之前完成,则在命令之间包含wait可能会有所帮助。

The first time you run it, it may ask you which program to use. 第一次运行它时,它可能会问您要使用哪个程序。 Choose Git for Windows . 选择Git for Windows

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM