cmder icon indicating copy to clipboard operation
cmder copied to clipboard

How do you create an alias?

Open notflip opened this issue 11 years ago • 48 comments

Hi

I want to create aliases to work a litle faster. Tried creating a .bashrc folder in my home dir but it's not working

Thanks

notflip avatar Mar 13 '15 09:03 notflip

You can create your aliases in the config/aliases folder or with the alias command. There was also a small part about aliases in the readme:

Aliases

You can define simple aliases with command alias name=command. For example there is one defined for you alias e.=explorer . All aliases will be saved in /config/aliases file

r3Fuze avatar Mar 13 '15 10:03 r3Fuze

To add some to answer above, current cmder (I don't know since when though) , once you have 'config/aliases' file created, on new console window launch automatically converts 'config/aliases' file to 'user-aliases.cmd', that works now in cmder.

power-media avatar Dec 06 '17 11:12 power-media

If I use the alias command it works but only for the given session. If I restart cmder it is not working anymore.

bruce-forte avatar Jan 23 '18 21:01 bruce-forte

@adam-arold, aliases need to be stored in config file to be persisted.

power-media avatar Jan 27 '18 18:01 power-media

I have my aliases in the config/aliases file and they don't work from Cmder. This is how this file looks like:

gcb="./gradlew clean build --parallel"
gfb="./gradlew assemble --parallel"

What could be the problem?

bruce-forte avatar Feb 02 '18 22:02 bruce-forte

@adam-arold Do you have a %cmder_root%\config\user-aliases.and file? Never versions of cmder 1.3.2+, I think, store aliases in this file.

daxgames avatar Feb 03 '18 02:02 daxgames

@adam-arold The alias command run in 'cmder' shell based on cmd.exe should write the alias to the file I mentioned in my last post preserving it for future sessions.

If using a 'bash' shell aliases created using the alias command are not saved unless you manually add them to '%cmder_root%/config/user-aliases.sh'

Since your aliases contain / and you say aliases are not preserved across sessions I assume you are using a bash shell.

daxgames avatar Feb 03 '18 02:02 daxgames

I have the user-aliases.sh file and the aliases are in it but they don't work.

bruce-forte avatar Feb 04 '18 18:02 bruce-forte

@adam-arold. File content?

Should look something like:

alias aliasname='cmd args'
alias aliasname2='cmd2 args2'

daxgames avatar Feb 04 '18 19:02 daxgames

ga=git add .
gc=git commit -am
gpm=git push origin
gpl=git pull origin

is this possible?

gpm myrepo gc "something"

justinlazaro-ubidy avatar Feb 08 '18 06:02 justinlazaro-ubidy

For some reason the alias command did not add the alias prefix to the entries in the user-aliases.sh so I ended up adding them by hand. Now it works, thanks!

bruce-forte avatar Feb 08 '18 20:02 bruce-forte

@adam-arold All is working as expected. The alias command in bash sets an alias for the running session only. To make it permanent and cmder portable you add it manually to the file I told you about. If you are not worked about it being portable the bash way would be to manually add it to the ~/.bashrc file.

daxgames avatar Feb 08 '18 22:02 daxgames

I have the user-aliases.cmd file and my aliases are in there. However, I cannot use any of the aliases in Cmder. Not even the default ones like e..

xelra avatar Feb 12 '18 22:02 xelra

@xelra what version of cmder? If not latest, download the latest and follow the upgrade procedure in the readme.md.

daxgames avatar Feb 12 '18 23:02 daxgames

@daxgames Thanks that fixed it. For some reason I was under the impression that Cmder was updating automatically.

xelra avatar Feb 12 '18 23:02 xelra

@justinlazaro-ubidy did you find solution ?

developandbehappy avatar Feb 25 '18 12:02 developandbehappy

Most examples/snippets I read included quotes when setting aliases.
That did not work for me. Solution:

Don't

alias gcm='git checkout master'

Do

alias gcm=git checkout master

maxpower9000 avatar May 23 '18 14:05 maxpower9000

How about passing the arguments on to the aliased command?

alias gd=git diff

Use it like:

gd --staged

jakoandersen avatar Jun 18 '18 09:06 jakoandersen

@maxpower9000 the "don't" is syntax for linux/Unix

The "do" is syntax for 'cmder' command alias.bat

daxgames avatar Jun 18 '18 22:06 daxgames

@jakoandersen is that a question? If so, Cmder aliases in cmd based shells are based on doskey. See the doskey macro docs details on how to do advanced aliases.

daxgames avatar Jun 18 '18 22:06 daxgames