Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest Windows 10 Update Breaks Aliases #1374

Closed
thatdoorsajar opened this issue May 16, 2017 · 39 comments
Closed

Latest Windows 10 Update Breaks Aliases #1374

thatdoorsajar opened this issue May 16, 2017 · 39 comments
Labels
👆 clink Upstream issue in clink.

Comments

@thatdoorsajar
Copy link

thatdoorsajar commented May 16, 2017

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.

@huihuiguoguo
Copy link

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.

@Demers94
Copy link

Demers94 commented May 21, 2017

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.

@alinnert
Copy link

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

@lunyx
Copy link

lunyx commented Jun 1, 2017

#1325

@illusive-man
Copy link

Same here...

@PixelTom
Copy link

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.

@nonsocode
Copy link

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

@mattanja
Copy link

mattanja commented Jul 4, 2017

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

@Foxandxss
Copy link

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

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

@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.

@illusive-man
Copy link

@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.

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

@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.

@illusive-man
Copy link

@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!

@Foxandxss
Copy link

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

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

@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.

@Foxandxss
Copy link

@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.

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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
λ

@Foxandxss
Copy link

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 :/

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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!

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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.

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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 ~
λ

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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

@Foxandxss
Copy link

I am using bash::bash indeed.

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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

@Foxandxss
Copy link

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

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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.

@Foxandxss
Copy link

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.

@daxgames
Copy link
Member

daxgames commented Jul 9, 2017

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.

@daxgames
Copy link
Member

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

@Foxandxss
Copy link

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

@daxgames
Copy link
Member

@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'

@adanski
Copy link

adanski commented Aug 2, 2017

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

@thatdoorsajar
Copy link
Author

thatdoorsajar commented Aug 16, 2017

@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

@daxgames
Copy link
Member

@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. mridgers/clink#464 for the fix you are looking for.

@Stanzilla Stanzilla added the 👆 clink Upstream issue in clink. label Aug 19, 2017
@daxgames
Copy link
Member

@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.

@Stanzilla
Copy link
Member

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

@ZodmanPerth
Copy link

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

@Stanzilla
Copy link
Member

@ZodmanPerth try one of those https://ci.appveyor.com/project/MartiUK/cmder/build/1.0.475-master/artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👆 clink Upstream issue in clink.
Projects
None yet
Development

No branches or pull requests