Skip to content

Instantly share code, notes, and snippets.

@manualbashing
Last active March 30, 2020 13:21
Show Gist options
  • Save manualbashing/e017fa5943dfea61778f4633401c24e2 to your computer and use it in GitHub Desktop.
Save manualbashing/e017fa5943dfea61778f4633401c24e2 to your computer and use it in GitHub Desktop.
Install Emacs26 on Ubuntu WSL (SpaceEmacs)
#!/usr/bin/env bash
# Checks if there's a frame open
emacsclient -n -e "(if (> (length (frame-list)) 1) 't)" 2> /dev/null | grep t &> /dev/null
if [ "$?" -eq "1" ]; then
emacsclient -a '' -nqc "$@" &> /dev/null
else
emacsclient -nq "$@" &> /dev/null
fi
function emacs {
[CmdletBinding()]
param (
[Parameter(Mandatory=$false, ValueFromPipeline=$true)]
[String[]]
$Path = ''
)
Begin{
$cmdTemplate = "cd ~; export DISPLAY=:0; /home/mbatsching/bin/em {0}"
}
Process {
foreach ($p in $Path) {
$p = Get-Item $p
$linuxPath = wsl wslpath -a ($p.FullName -replace '\\', '\\') ## Preserve backslashes
$cmd = $cmdTemplate -f ($linuxPath -replace ' ', '\ ') ## Escape spaces
cmd /c C:\Windows\System32\wscript.exe C:\\Users\\m.batsching\wslu\runHidden.vbs bash.exe -c $cmd
}
}
End {
}
}

On WSL:

sudo add-apt-repository ppa:kelleyk/emacs
sudo apt-get update
sudo apt install emacs26
git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
sudo apt install xfce4
echo "export DISPLAY=:0.0" >> ~/.bashrc
source ~/.bashrc

Source

On Windows:

choco install vcxsrv

Inside WSL: Create short cut to windows Desktop

wslusc -g /home/mbatsching/bin/em

Install missing font

wget https://github.com/adobe-fonts/source-code-pro/archive/2.030R-ro/1.050R-it.zip
unzip 1.050R-it.zip 
if [ ! -d "~/.fonts" ] ; then
    mkdir ~/.fonts
fi
cp source-code-pro-*-it/OTF/*.otf ~/.fonts/
fc-cache -f -v

add this to bashrc

export PATH=$PATH:~/bin
cd ~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment