How do you create an alias?
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
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
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.
If I use the alias command it works but only for the given session. If I restart cmder it is not working anymore.
@adam-arold, aliases need to be stored in config file to be persisted.
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?
@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.
@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.
I have the user-aliases.sh file and the aliases are in it but they don't work.
@adam-arold. File content?
Should look something like:
alias aliasname='cmd args'
alias aliasname2='cmd2 args2'
ga=git add .
gc=git commit -am
gpm=git push origin
gpl=git pull origin
is this possible?
gpm myrepo
gc "something"
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!
@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.
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 what version of cmder? If not latest, download the latest and follow the upgrade procedure in the readme.md.
@daxgames Thanks that fixed it. For some reason I was under the impression that Cmder was updating automatically.
@justinlazaro-ubidy did you find solution ?
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
How about passing the arguments on to the aliased command?
alias gd=git diff
Use it like:
gd --staged
@maxpower9000 the "don't" is syntax for linux/Unix
The "do" is syntax for 'cmder' command alias.bat
@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.