Cmder: why the alias not work in the cmder?

Created on 9 Jul 2017  路  10Comments  路  Source: cmderdev/cmder

This is my alias file which in the path "cmder\config\", I don't know why the cl , gl :x command not work anymore.

e.=explorer .
gl=git log --oneline --all --graph --decorate $*
pwd=cd
cl=clear
history=cat %CMDER_ROOT%\config.history
unalias=alias /d $1
his=DOSKEY /HISTORY
:x=exit
vi=gvim
ls=dir
ip=ipconfig
reboot=shutdown /r /t 20
c=cd

Most helpful comment

Related mridgers/clink#464


Quick fix:

Download the latest release here: https://github.com/Stanzilla/clink/releases/latest, copy & paste to ./cmder/vendor/clink and update the .cmderver file there.

... or wait for the next release of cmder, which should have that included.


Issue is resolved upstream.

All 10 comments

The latest cmder releases use a new format for the alias file. Read the docs. Also even if you get the latest version and the alias file format to match you could still experience an issue with the latest versions of Windows breaking aliases in cmd based shells.

Read the docs? A simple pointer would be helpfull, because:

Aliases

There is simple support for aliases. They can be created by using the alias command like this: alias ls=ls -- color $. They are pretty much just doskeys in /config/aliases. One per line. And make sure to handle arguments by putting argument variables $ somewhere.
-- http://cmder.net/

Sorry was busy when I replied to this, probably should have waited. I just went to the docs myself and they are incomplete. I will be updating them.

I you are using a current version of cmder and upgraded from an older version that used '%CMDER_ROOT%/config/aliases' it 'should have auto-updated that 'aliases' file to the new '%CMDER_ROOT%/config/user-aliases.cmd'. If it did not I need to know that.

If starting fresh with a newly downloaded cmder in a new directory then '%CMDER_ROOT%/config/user-aliases.cmd' should have been automatically created at first run. If it did not I need to know that.

To fix what you have make sure you are running cmder 1.3.2, rename 'aliases' to 'user-aliases.cmd' and add the below to the top of the file:

;= @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

Related mridgers/clink#464


Quick fix:

Download the latest release here: https://github.com/Stanzilla/clink/releases/latest, copy & paste to ./cmder/vendor/clink and update the .cmderver file there.

... or wait for the next release of cmder, which should have that included.


Issue is resolved upstream.

@jrappen

Thank you sooooo much. That's been bugging me for nearly a year. Finally decided to Google it, and your solution did the trick.

Thanks a million!

@flatline-studios you can thank @Stanzilla for the fix

@jrappen Didn't quite work for me using latest version of cmder (which appears to be called version "180626")

I followed the instructions, but there was no path/to/cmder/config/aliases file. So I made one. I tried a few different kind of syntax attempts, but every time I loaded cmder, it said something like "invalid alias found; converting to new style", and it deleted the aliases file, and placed the entries at the bottom of the path/to/cmder/config/user_aliases.cmd file.

I made some edits, and now I'm getting python2 and python3 aliases working on Windows in cmder. Here's a snippet of my user_aliases.cmd file:

;= @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%"
python3="c:\Program Files (x86)\Python37-32\python"
python2="c:\Program Files (x86)\Python27-15\python2.exe"

Closing resolved in latest Clink/Cmder

# cmder_path_here/cmder/config/user_profile.cmd

@echo off
set "PATH=%homepath%\AppData\Roaming\Python\Python37\Scripts;%homepath%\repos\executables;%PATH%"

# in %homepath%\repos\executables folder I copied the executables I need, feel free to change

AutoHotkeyU64.exe
kubectl.exe
terraform.exe
procexp64.exe
etc.

python, kubectl, terraform etc. commands are working now

PS: as @daxgames mentioned %cmder_root%\bin is the proper folder to store executable files. I had to do it differently because other applications are looking for executables in my \repos\executables folder and did not want to have duplicates in %cmder_root%\bin as well.

@jturi that is what the %cmder_root%\bin folder is for. Any executeable file copied there is in the cmder session path without having to add the the path env var using %cmder_root%\config\user_profile.cmd

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AaronKaa picture AaronKaa  路  3Comments

spooky picture spooky  路  3Comments

giuliannosbrugnera picture giuliannosbrugnera  路  3Comments

luisrudge picture luisrudge  路  3Comments

jordanrobinson picture jordanrobinson  路  3Comments