How to create an alias for multiple commands in ConEmu?

5

2

In Git-Bash I have an alias that executes two commands; update the list of branches for a git repository, then print them:

alias glb='git remote update origin --prune && git branch -a'

How do I do this in ConEmu? Specifically, Cmder for Windows.

Since ConEmu doesn't use quotes with alias, I have to type alias glb=git remote update origin --prune && git branch -a which is interpreted as two separate commands, first alias glb=git remote update origin --prune and then git branch -a.

craigpatik

Posted 2015-10-13T17:56:30.117

Reputation: 177

The answer depends on shell you are using and exact place where you are trying to configure alias – Maximus – 2015-10-13T22:53:39.163

It's Cmder for Windows. I updated the question to clarify this. – craigpatik – 2015-10-14T11:21:56.323

I've asked about shell too! cmder is a terminal. – Maximus – 2015-10-14T15:35:11.830

1Actually, if you are using cmd.exe, you may just use double quotes instead of single ones. – Maximus – 2015-10-14T15:38:12.237

Answers

10

Command separator in ConEmu for me (on Windows) is:

$t

So your example would be:

alias glb=git remote update origin --prune $t git branch -a

NOTE: Be sure to restart your conemu window or open a new tab in order for this to apply. - thanks to @vetras for reminding me.

Reference: http://artandlogic.com/2013/06/making-the-windows-command-prompt-suck-slightly-less/

Eric Steinborn

Posted 2015-10-13T17:56:30.117

Reputation: 603

2works but we need to close and start cmdr after we update the alias -- if we change the file on an editor. Took some time to get that. – Vetras – 2016-11-22T11:58:04.180

1You can get around having to restart CMDer simply by reloading the aliases via alias /reload. If for some reason that doesn't work, the full command is %SystemRoot%\system32\doskey /macrofile=Path\To\Your\user-aliases.cmd – Nathan – 2017-12-03T15:38:46.057

3

Open user-aliases.cmd file under \path\to\cmder\config to add the alias directly, then restart the cmder. glb=git remote update origin --prune $t git branch -a

user709492

Posted 2015-10-13T17:56:30.117

Reputation: 31