Cmder: Latest Windows 10 Update Breaks Aliases

Created on 16 May 2017  路  39Comments  路  Source: cmderdev/cmder

Everything was working just as normal. All my aliases were being read from \cmder\config\user-aliases.cmd then I ran the most recent Windows 10 update and the aliases stopped working. Everything else works fine including the user-profile.cmd.

I deleted cmder and reinstalled but the exact same problem continues. If this is a problem with the Windows 10 update then sorry for posting here but I imagine it will be a problem the cmder team need to address.

EDIT

Aliases can be stored to the file using alias foo=bar but cannot be read from the file by using foo.

馃憜 clink

Most helpful comment

All 39 comments

It also appears on my windows 10. Run alias "ll" will get the following error.
'll' is not recognized as an internal or external command, operable program or batch file.

Same problem here, aliases stopped working after the latest major W10 update.

The colour highlighting for files/folders (ex: when running ls inside a directory) is also gone, although I'm not sure if this is as a result of the update or something else.

@Demers94 That's because there's this default alias: ls=ls --show-control-chars -F --color $* which of course also stopped working.

1325

Same here...

I really love Cmder, but these broken aliases have really cut into my productivity. I've switched to Git Bash for now but I'd love to see a fix soon.

Mine started working again this morning. When i opened cmder I got this message

Clink v0.4.8 [git:d565ad] Copyright (c) 2012-2016 Martin Ridgers
http://mridgers.github.io/clink

Now all aliases seem to be working just fine and i can also use bash in cmder

For me this is also a blocker in using cmder - is there a chance this will be fixed?
Related issue has been closed: https://github.com/cmderdev/cmder/issues/1257
@nonsocode The Clink update did not help in my case - using same version 0.4.8 without changed behavior...

As a bash:bash user, I have a .bashrc profile inside my user folder. I put all aliases in there and they work!

@Foxandxss the only issue with that approach is that the aliases are not portable. Maybe not an issue for you but cmder best practice would be to put the aliases and any other shell specific config in a *.cmd,
*.ps1, *.sh file in $CMDER_ROOT/config/profile.d and then you could zip up the entire cmder folder and take it all with you.

@daxgames please read issue's description. It clearly states that problem is with *.cmd config (for cmd.exe). There is no problem with bash and PS aliases. And (surprise) you can store your aliases for bash along with cmder, but you do it in user-profile.sh file which is in cmder/config folder. BUT if there is the config file in the User home dir, it will have greater priority over cmder dir config. So aliases are portable and you can take it all with you! The following example works great on latest Windows 10 Pro 1703 15063.413.

alias hd='cd /c/Users/UserNameHere'
alias edit='atom.exe $*'
alias cls=clear

BTW for PowerShell, there's its own alias format. Check the official docs if you need it.

@illusive-man not sure why you pointed this at me. I am fully aware of how it works since I wrote the profile.d code in cmder and what the issue is.

I was just pointing out to @foxandxss the definite lack of portability in using an alias store outside the cmder folder.

Indeed you can store aliases in config/user-profile.sh, I wrote part of that too, but putting all the config in one monolithic file can get a little messy. You can just drop a file in profile.d whose extension matches the shell you are running and it will become a part of that shells initialization.

@daxgames Don't get me wrong, but I didn't get it at first that you were talking to Foxandxss. Sorry, my bad!

Well, personally I'm using like 10-20 aliases on a daily basis. So for me, config/user-profile.sh is more than enough. But I will try and use your advice on profile.d folder. Thanks for the precious hint!

The problem with config/user-profile.sh for me is that they don't autoload anymore, or at least for me (since creator update)

@illusive-man No problem. I have like 500+ aliases makes the file a little large.

@Foxandxss If they load from ~/.bashrc and not from $CMDER_ROOT/config/user-profile.sh then I am betting the issue is not the creator update. The Creator update issue is specifically an issue with cmd.exe doskey macros and clink a component used by cmder to provide bash like command completion and other things to cmd.exe. I will look and see if I have the same issue and let you know.

@daxgames They were working fine until the creator update. I remember updating to it and they stopped working.

I had to source $CMDER_ROOT/config/user_profile.sh to load them per tab basis. The .bashrc is just a new workaround.

Just confirmed it. I am on Microsoft Windows [Version 10.0.15063].

Running bash->bash in cmder loads aliases from both $CMDER_ROOT/config/user_profile.sh and from $CMDER_ROOT/config/profile.d/*.sh.

Output from brand new bash->bash with no ~/.bashrc

dgames@DTG-WS ~
位 alias upsh
alias upsh='echo I am an alias from the $CMDER_ROOT/config/user-profile.sh'
dgames@DTG-WS ~
位 upsh
I am an alias from the /c/Users/dgames/cmder/config/user-profile.sh
dgames@DTG-WS ~
位 ls ~/.bash*
/c/Users/dgames/.bash_history
dgames@DTG-WS ~
位

The same does not work for doskey aliases when launching cmder->cmder as expected.

C:\Users\dgames
位 alias cmderr
cmderr=cd /d "%CMDER_ROOT%"

C:\Users\dgames
位 cmderr
'cmderr' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\dgames
位
foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$ gst
bash: gst: command not found

foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$ cat ~/Documents/cmder/config/user-profile.sh

# use this file to run your own startup commands for msys2 bash'

# To add a new vendor to the path, do something like:
# export PATH=${CMDER_ROOT}/vendor/whatever:${PATH}

alias gaa='git add --all'
alias gcb='git checkout -b'
alias gst='git status'
alias ggpush='git push origin $(git rev-parse --abbrev-ref HEAD)'
alias updups='git fetch upstream && git rebase upstream/master && ggpush'
foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$ source ~/Documents/cmder/config/user-profile.sh

foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$ gst
fatal: Not a git repository (or any of the parent directories): .git

foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$ cd ~

foxan@DESKTOP-G0E7BTC MINGW32 ~
$ mv foo .bashrc

I restart cmder....

foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$ gst
fatal: Not a git repository (or any of the parent directories): .git

foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$

Doesn't work for me :/

Odd. Maybe we are on diff versions of cmder. Also are you using Cmder's bash or windows 10 ubuntu bash?

Just for arguments sake I commented the clink load bits from %CMDER_ROOT%/ventor/init.bat and now launching cmder->cmder aliases now work:

C:\Users\dgames>alias cmderr
cmderr=cd /d "%CMDER_ROOT%"

C:\Users\dgames>cmderr

C:\Users\dgames\cmder>

But we lose all the niceties clink provides.

Have you tried building cmder from source? It is easy:

  1. Download https://github.com/cmderdev/cmder/archive/master.zip
  2. Expand it into a new folder.
  3. Open a Powershell.exe shell outside cmder.
  4. Close all cmder windows.
  5. Change to the '[dir you expanded into]\scripts'
  6. Type './build.ps1 -verbose'

You should see:

C:\Users\dgames\cmder\scripts> .\build.ps1 -verbose
VERBOSE: Backup '..\vendor\conemu-maximus5\ConEmu.xml' to '..\config\ConEmu.xml'
VERBOSE: Getting git-for-windows from URL
https://github.com/git-for-windows/git/releases/download/v2.13.2.windows.1/PortableGit-2.13.2-32-bit.7z.exe
VERBOSE: Remove tmp/git-for-windows.tmp
VERBOSE: Remove git-for-windows
VERBOSE: Downloading from
https://github.com/git-for-windows/git/releases/download/v2.13.2.windows.1/PortableGit-2.13.2-32-bit.7z.exe to
C:\Users\dgames\cmder\vendor\tmp\git-for-windows.tmp
VERBOSE: Extracting Archive 'C:\Users\dgames\cmder\vendor\tmp\git-for-windows.tmp to 'C:\Users\dgames\cmder\vendor\git-for-windows'
VERBOSE: Getting clink from URL https://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip
VERBOSE: Remove tmp/clink.tmp
VERBOSE: Remove clink
VERBOSE: Downloading from https://github.com/mridgers/clink/releases/download/0.4.8/clink_0.4.8.zip to C:\Users\dgames\cmder\vendor\tmp\clink.tmp
VERBOSE: Extracting Archive 'C:\Users\dgames\cmder\vendor\tmp\clink.tmp to 'C:\Users\dgames\cmder\vendor\clink'
VERBOSE: Getting conemu-maximus5 from URL https://github.com/Maximus5/ConEmu/releases/download/v17.06.22/ConEmuPack.170622.7z
VERBOSE: Remove tmp/conemu-maximus5.tmp
VERBOSE: Remove conemu-maximus5
VERBOSE: Downloading from https://github.com/Maximus5/ConEmu/releases/download/v17.06.22/ConEmuPack.170622.7z to
C:\Users\dgames\cmder\vendor\tmp\conemu-maximus5.tmp
VERBOSE: Extracting Archive 'C:\Users\dgames\cmder\vendor\tmp\conemu-maximus5.tmp to 'C:\Users\dgames\cmder\vendor\conemu-maximus5'
VERBOSE: Getting clink-completions from URL https://github.com/vladimir-kotikov/clink-completions/archive/0.3.2.zip
VERBOSE: Remove tmp/clink-completions.tmp
VERBOSE: Remove clink-completions
VERBOSE: Downloading from https://github.com/vladimir-kotikov/clink-completions/archive/0.3.2.zip to
C:\Users\dgames\cmder\vendor\tmp\clink-completions.tmp
VERBOSE: Extracting Archive 'C:\Users\dgames\cmder\vendor\tmp\clink-completions.tmp to 'C:\Users\dgames\cmder\vendor\clink-completions'
VERBOSE: Restore '..\config\ConEmu.xml' to '..\vendor\conemu-maximus5\ConEmu.xml'
WARNING: You are not building a launcher, Use -Compile
WARNING: This cannot be a release. Test build only!
VERBOSE: Adding cmder.sh /etc/profile.d
VERBOSE: Replacing /etc/profile.d/git-prompt.sh with our git-prompt.sh
VERBOSE: All good and done!

You may need to update powershell if you are running version 2. I can't remember if it will build on powershell 2. To check type $PSVersionTable inside powershell.

After looking back at your output you appear to not be running the cmder 1.3.2+ or you are not running cmder's bash, or you customized your prompt to not use cmders prompt.

Notice the difference in the prompt:

You:

foxan@DESKTOP-G0E7BTC MINGW32 ~/Documents/Programming
$

Me:

dgames@DTG-WS ~
位

Wierd I just built from source and my prompt matches yours which means something is broken. but my aliases still work as expected.

I am using bash::bash indeed.

Change to $CMDER_ROOT and type . vendor/git-for-windows/etc/profile.d/git-prompt.sh

This should make your prompt look like mine. For come reason this is not happening automatically as it should be.

You could also type: . vendor/git-for-windows/etc/profile.d/cmder.sh which is the file that handles loading of stuff in $CMDER_ROOT/config and $CMDER_ROOT/config/profile.d

I have updated mine to include some strategic echo messages to help debug the issue:

if [ -d "${CMDER_ROOT}/config/profile.d" ] ; then
  unset profile_d_scripts
  pushd "${CMDER_ROOT}/config/profile.d" >/dev/null
  profile_d_scripts=$(ls *.sh 2>/dev/null)

  if [ ! "x${profile_d_scripts}" = "x" ] ; then
    for x in ${profile_d_scripts} ; do
      echo Sourcing "${CMDER_ROOT}/config/profile.d/${x}"...
      . "${CMDER_ROOT}/config/profile.d/${x}"
    done
  fi
  popd >/dev/null
fi

if [ -f "${CMDER_ROOT}/config/user-profile.sh" ] ; then
    echo "Sourcing ${CMDER_ROOT}/config/user-profile.sh"
    . "${CMDER_ROOT}/config/user-profile.sh"
else
    echo Creating user startup file: "${CMDER_ROOT}/config/user-profile.sh"
    cat <<-eof >"${CMDER_ROOT}/config/user-profile.sh"
# use this file to run your own startup commands for msys2 bash'

# To add a new vendor to the path, do something like:
# export PATH=\${CMDER_ROOT}/vendor/whatever:\${PATH}
eof
fi

# Source the users .bashrc file if it exists
if [ -f "${HOME}/.bashrc" ] ; then
    echo "Sourcing ${HOME}/.bashrc"
    . "${HOME}/.bashrc"
fi

Now when I launch bash I get the below:

running git-for-windows/etc/profile.d/cmder.sh
Sourcing /c/Users/dgames/cmder/config/profile.d/user-aliases.sh...
Sourcing /c/Users/dgames/cmder/config/user-profile.sh

What is . vendor/git-for-windows/etc/profile.d/cmder.sh doing? I never saw the . app. And I don't have the cmder.sh.

But thanks for the git-prompt.sh. I changed it to just include the route and git stuff.

So far, I am ok with it sourcing the .bashrc

If you do not have the cmder.sh then there is something amiss with your cmder install. Possibly it is old as I said earlier.

'.' is same as 'source' in bash. I understand you are OK with it because it works for you. I wrote this code so if it is somehow broken for some I want to fix it so I need your help since I cannot reproduce the issue on my own.

I just fixed the git prompt not auto-loading and will be doing a PR toy resolve the issue.

Thanks man. It is not like I have an old cmder. I remember killing the git-for-windows vendor and putting a new one while trying to have back my aliases.

If you have a git-for-windows folder that did not come from a cmder full binary distro that that explains the issue. We add cmder.sh and replace git-prompt.sh with our own versions during package build. You can copy vendor/cmder.sh to the path I gave you earlier and it will fix your alias loading issue.

You may need to get cmder.sh from the zip I asked you to download earlier to attempt a build from source.

@Foxandxss Was my last message accurate or is there something else that needs to be foxed?

I bet it is Dax, but honestly, I haven't try to revert. I need cmder to work for well, work :P

@Foxandxss I understand, I do too. Just so you and others know, no 'revert' is required.

We add cmder.sh and replace git-prompt.sh with our own version during package build. These are the only changes we make to the core git-for-windows distribution.

You can simply copy cmder.sh to '$CMDER_ROOT/vendor/git-for-windows/etc/profile.d/cmder.sh' and it will make profile settings load when a cmder bash session is started as designed in the following order:

  • '$CMDER_ROOT/config/profile.d/*.sh'
  • '$CMDER_ROOT/config/user-profile.sh'
  • '$userprofile/.bashrc'

@daxgames, there is a PR with a fix for this issue in clink: https://github.com/mridgers/clink/pull/464
The project seems to be not maintained anymore, unfortunately.

@daxgames I have exactly the same cmder.sh that you posted in your solution to @Foxandxss but my aliases don't load as per the original issue post.

I have just downloaded Cmder from website and then updated cmder.sh to be the same as the cmder.sh you posted just to be sure, restarted cmder and still no aliases working.

Anybody else still having this issue? Also is there a workaround which can be implemented in the meantime? Having no aliases is driving me nuts.

Thanks for the help

@thatdoorsajar the fix I posted was for that specific user complaining of aliases not working in Bash if stored in the cmder/config folder because he had deleted cmder.sh. He was trying to fix the issue in this post and inadvertently created a completely unrelated issue.

As stated earlier aliases not loading in cmder cmd sessions are related to an issue with clink. See. https://github.com/mridgers/clink/pull/464 for the fix you are looking for.

@stanzilla when are we going to start using your clink fork to fix this? I am using "https://ci.appveyor.com/api/buildjobs/9s1asp19s0hoq7g4/artifacts/.build%2Frelease%2F20170816_247112%2Fclink_DEV.zip" in my sources.json and building using scripts/build.ps1 and it fixes my macros in cmder cmd sessions.

I kinda wanted to wait for the Readline update PR dude to come back but I guess now is a good time as any.

@Stanzilla your fix still hasn't been applied. I started using the fix from @KayLeung on his Google drive (as per https://github.com/mridgers/clink/pull/464) and am very ecstatic with the result.
This fix should totally be in a new release of Cmder.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bmeverett picture bmeverett  路  3Comments

brunowego picture brunowego  路  3Comments

jenisys picture jenisys  路  3Comments

emesx picture emesx  路  3Comments

vincentntang picture vincentntang  路  3Comments