diff --git a/README.md b/README.md index 18cdda2..c97f002 100644 --- a/README.md +++ b/README.md @@ -22,12 +22,21 @@ __Linux:__ - Gnome (or a derivative) - gVim +__Windows:__ + +- AutoHotKey +- gVim + #### Install ```bash curl -fsSL https://raw.github.com/cknadler/vim-anywhere/master/install | bash ``` +```powershell +iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/cknadler/vim-anywhere/master/install.ps1')) +``` + __OSX caveat:__ key binding is unbound by default. See [keybinding](#keybinding) for details. @@ -67,6 +76,10 @@ $ echo "bindsym $mod+Alt+v exec ~/.vim-anywhere/bin/run" >> ~/.i3/config # remem ``` Adjust in case `$mod` is not set to ctrl. +__Windows:__ + +Check the `AutoHotkey` example file from `script/hotkey.example.ahk` + ## History vim-anywhere creates a temporary file in `/tmp/vim-anywhere` when diff --git a/bin/run.ps1 b/bin/run.ps1 new file mode 100644 index 0000000..d61dacc --- /dev/null +++ b/bin/run.ps1 @@ -0,0 +1,19 @@ +function Find-BinaryPath() { + $VimBinaries = @( + "${env:ProgramFiles(x86)}\vim\vim80\gvim.exe", + "$env:ProgramFiles\vim\vim80\gvim.exe" + ) + foreach($Path in $VimBinaries) { + if (Test-Path -Path "$Path") { + return "$Path" + } + } +} + +$VimPath = Find-BinaryPath +$TempFile = "$env:LOCALAPPDATA\.vim-anywhere" + +Start-Process "$VimPath" -Args "$TempFile", "--nofork" -Wait +Get-Content "$TempFile" | Set-Clipboard +Remove-Item -Force -Path "$TempFile" + diff --git a/install.ps1 b/install.ps1 new file mode 100644 index 0000000..5825945 --- /dev/null +++ b/install.ps1 @@ -0,0 +1,13 @@ +# Add zip assembly +Add-Type -AssemblyName System.IO.Compression.FileSystem + +# Download from Github +Invoke-WebRequest -Uri "https://github.com/cknadler/vim-anywhere/archive/master.zip" -OutFile "$env:LOCALAPPDATA\vim-anywhere.zip" + +# Extract +[System.IO.Compression.ZipFile]::ExtractToDirectory("$env:LOCALAPPDATA\vim-anywhere.zip", "$HOME") + +# Setup +Move-Item "$HOME\vim-anywhere-master" "$HOME\.vim-anywhere" +Remove-Item -Force "$env:LOCALAPPDATA\vim-anywhere.zip" + diff --git a/script/hotkey.example.ahk b/script/hotkey.example.ahk new file mode 100644 index 0000000..339b0e2 --- /dev/null +++ b/script/hotkey.example.ahk @@ -0,0 +1,3 @@ +^!V:: ; vim-anywhere +Run C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden %HOMEDRIVE%\%HOMEPATH%\.vim-anywhere\bin\run.ps1 +Return