plexus / chemacs

Emacs profile switcher
652 stars 45 forks source link

Wrong .emacs path on Windows 10 #28

Open shaund opened 4 years ago

shaund commented 4 years ago

The current powershell script tries to deal with this, but even though I hadn't set %HOME%, it still copied .emacs to C:/Users/<username>/ instead of c:/Users/<username>/AppData/Roaming/

To get it to work, I ran in powershell

[Environment]::SetEnvironmentVariable("HOME", "C:\Users\$env:UserName", "User")

Then used this https://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html#download to create a symlink to the .emacs file in C:/Users/$env:UserName/. (You could also use #18.)

plexus commented 4 years ago

I'm not really up to date on the Powershell situation since I rarely use Windows. Any chance you could add some instructions to the README for people that come looking for what to do?

shaund commented 4 years ago

Sure, see below. I think the current script could even be modified to do the first option automatically.


In PowerShell:

  1. cd to where you want to keep chemacs (e.g. cd C:\Users\$env:UserName)
  2. clone chemacs: git clone https://github.com/plexus/chemacs.git
  3. create the %HOME% variable emacs uses:
  4. create a hardlink from chemacs's .emacs to your home directory:
    New-Item -Path C:\Users\$env:UserName\.emacs -ItemType HardLink -Target chemacs\.emacs

Note this uses a hardlink so you don't need admin rights. Hardlinks only work on the same drive/filesystem. If you have admin rights and want to create it on a different drive, then follow the following steps instead.

I'll use D:\MySpecialHome as the example for where you want your emacs home directory to be.

In PowerShell:

  1. open another PowerShell, this one as admin:
    Start-Process powershell -Verb runAs
  2. a UAC dialog will pop up, confirm it to open the admin PowerShell
  3. now in the admin PowerShell, cd to where you want to keep chemacs: cd D:\MySpecialHome
  4. clone chemacs: git clone https://github.com/plexus/chemacs.git
  5. create the %HOME% variable emacs uses:
  6. create a symlink from chemacs's .emacs to your home directory:
    New-Item -Path D:\MySpecialHome\.emacs -ItemType SymbolicLink -Target chemacs\.emacs
plexus commented 4 years ago

Great! Could you add this to the README please? (i.e. pull request?)