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
I'm using Cmder Version 180528
In \cmder\vendor\, there is a file called user-aliases.cmd.example, it contains the following:
;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here
e.=explorer .
gl=git log --oneline --all --graph --decorate $*
ls=ls --show-control-chars -F --color $*
pwd=cd
clear=cls
gg=cls
history=cat "%CMDER_ROOT%\config\.history"
unalias=alias /d $1
vi=vim $*
cmderr=cd /d "%CMDER_ROOT%"
I duplicated this file and rename the duplicated file to user-aliases.cmd.
That is, I now have a \cmder\vendor\user-aliases.cmd
I add ll=ls -al to the last line of the file. Save it.
But in Cmder, I still cannot use the command ll. What am I doing wrong?
The *.example it's supposed to be copied to the config folder and named what you named it on first launch if it doesn't already exist. If that didn't happen there's probably a bug in the init.bat. if you copy it there manually you should start having some default aliases
@daxgames Thanks for the tips.
Instead of \cmder\vendor\user-aliases.cmd, which does not work.
Now I have \cmder\config\user-aliases.cmd, which is working, thanks you.
Does that look wrong? https://github.com/cmderdev/cmder/blob/master/vendor/init.bat#L253
I have %cmder_root%\config\user-aliases.cmd. It came pre-installed with Laragaon but none of the aliases in it work. vendor\init.bat does seem to be trying to load it.
When I do alias vi=vim on the command line, vi continues to not work.
The solution that seemed to have worked (cmder ^v1.3.6)
Open up the following in your text editor: CMDER_ROOT/config/user-aliases.cmd
Extend the file by appending aliases you need:
;= @echo off
;= rem Call DOSKEY and use this file as the macrofile
;= %SystemRoot%\system32\doskey /listsize=1000 /macrofile=%0%
;= rem In batch mode, jump to the end of the file
;= goto:eof
;= Add aliases below here
e.=explorer .
gl=git log --oneline --all --graph --decorate $*
ls=ls --show-control-chars -F --color $*
pwd=cd
clear=cls
history=cat "%CMDER_ROOT%\config\.history"
unalias=alias /d $1
vi=vim $*
cmderr=cd /d "%CMDER_ROOT%"
ll=ls -la
Hope this helps you guys!
https://github.com/cmderdev/cmder/issues/421#issuecomment-364017376 @justinlazaro-ubidy
Totally possible just use $* e.g. gpm=git push origin $* gc=git commit -am $*
Not sure if I am being thick (most likely cause its late) but im trying to add alias k=kubectl
It is in the config file but i get error. Also the e. does not work either?
🆘 Help 🆘

--Edit
I just realised the user_aliased.cmd is for the command and I am running in PowerShell... so I used PowerShell Set-Alias which worked. Maybe will help another noob later 🍜
How about passing the arguments on to the aliased command?
alias gd=git diffUse it like:
gd --staged
This didn't work out for me. I'd like to create an alias where I could pass the parameter manually. alias r=php artisan migration:refresh So when I run r --seed the console just count the r without the parameter --seed Can someone help me with this?
I think there is a misunderstanding with what to put it in the aliases file.
if you put alias ll=ls -la it doesn't seem to work because of the preceding alias flag. It's already in the aliases file. Just put any command you want to create an alias to with a preferred name into cmder/config/user-aliases.cmd like this ll=ls -al save the file restart cmder.
Cmder cmd session aliases are based on doskey. Look there for syntax.
Also no need to restart cmder, just execute user_aliases.cmd if you edit it directly.
In case anyone still strugling with creating aliases for bash shell, adding them to %cmder_root%/config/user_profile.sh with this syntax alias la='ls -la' worked for me.
Hi @daxgames and everyone!
Having issues - I'm using Bash / Ubuntu distribution {WSL::bash}. Running cmder out of my downloads folder at the moment /mnt/c/users/Laptop/Downloads/cmder. I run that executable. Certain default aliases work - for example, clear=cls does clear my screen. however, changes to user-aliases.sh or user-aliases.cmd don't have any effect. If I switch clear to clear1, clear is still the working command.
It seems to be referencing a different user-aliases file tahtn what i'm changing. Thoughts?
I'm modding:
%CMDER_ROOT%/config/user-aliases.sh
%CMDER_ROOT%/config/user-aliases.cmd
Thanks in advance.
@bholmquist11 WSL Bash is technically an external *nix env according to cmder. You have two choices:
- Add aliases to your
~/.bashrcor~/.bash_profile- Note: These aliases are not portable and are specific to this machine
- See this in the
README.md.
Thanks @daxgames!
hey guys I just installed cmder on windows 7 and i am trying to make this command work, could you help me out!?
dhall-to-json` --pretty <<< '[ ./example.dhall, ./example.dhall ]'
it says that << can not be used here. I am in a cmd.exe tab
Found it in the "Creating a macro" section in doskey
| $1 through $9 | Represent any command-line information you want to specify when you run the macro. The special characters $1 through $9are batch parameters that enable you to use different data on the command line each time you run the macro. The $1character in a doskey command is similar to the %1 character in a batch program. |
|---|---|
| $* | Represents all the command-line information that you want to specify when you type the macro name. The special character $* is a replaceable parameter that is similar to the batch parameters $1 through $9, with one important difference: everything you type on the command line after the macro name is substituted for the $* in the macro. |
@jakoandersen @Zontir this worked from me
alias g=git $*
# or
alias gd=git diff $*
In case anyone still strugling with creating aliases for
bashshell, adding them to%cmder_root%/config/user_profile.shwith this syntaxalias la='ls -la'worked for me.
After quite a bit of searching this is the one that did it for me in cmder bash. Thank you! Duplicating the user-aliases file as user-aliases.sh did nothing.
Note for others - you still need to restart the active console to have your changes apply.
Didn't see anyone commenting about this option so here it is... If you're using bash, from git for windows for exemple, you can add your alias to the alias.sh file in "cmder\vendor\git-for-windows\etc\profile.d" with this sintax: E.g: alias dev='cd E:/Files/Projetos && code'
Is there any way to pass default arguments?
I have the alias ngk=ngrok http $* and I have to pass the arguments (here, the port) as ngk 3000. Can I set some defaults such that when I just call ngk then it starts as ngk 3000?
P.S. I could make a separate alias but just wanted to know.