3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Bat】【vim】香り屋Vimをダウンロードしてインストールまでするbatファイル

Posted at

概要

香り屋版vimを更新するnetupvimをgithubからダウンロードして解凍して
指定フォルダにインストールするバッチファイル
対象はnetupvim ver1.3
オプションでダウンロードまでと展開までで終了させることも可能

コマンドプロンプト単体だと力不足だったのでパワーシェルにもがんばってもらう

本体

今回は :terminal を使いたいのでdevelop版をインストールする
インストール先は C:/Path/vim80

setup.bat
@echo off

setlocal

@rem ファイル名
set targetfilename=netupvim-v1.3.zip
@rem ソースファイル置き場
set sourcepath=https://github.com/koron/netupvim/releases/download/v1.3/
@rem 出力先( デフォルトはここ )
set exportDir=%CD%
@rem 自動展開 ( 1 で有効化 )
set autoextract=1
@rem 自動インストール
set autoinstall=1
@rem インストールvim
@rem コメントアウトしても良い
@rem release develop canaly vim.org のいずれか 詳細はhttps://github.com/koron/netupvim を参照 省略するとrelease
set viminstallmode=develop
@rem vimのインストールパス
set viminstallpath=C:\Path\vim80
@rem リストア
set restore=0


@rem 展開先フォルダ(自動指定)
set targetdir=%targetfilename:~0,-4%

@rem 展開されたフォルダがあるならインストールするかチェック
if exist %exportDir%\%targetdir% goto CheckInstall

@rem ダウンロードされたデータがあるなら展開へ
if exist %exportDir%\%targetfilename% GOTO Extract

:Download

@powershell -NoProfile -ExecutionPolicy Bypass -Command "$d=new-object System.Net.WebClient; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; $d.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetWorkCredentials; $d.DownloadFile('%sourcepath%%targetfilename%','%exportDir%/%targetfilename%')"

if %autoextract% NEQ 1 goto EOF

:Extract
@powershell -NoProfile -ExecutionPolicy Bypass -Command "expand-archive %targetfilename%"

:CheckInstall
if %autoinstall% NEQ 1 goto EOF
:MakeIni
cd %exportDir%\%targetdir%
set /a ismake=0
if defined viminstallmode set /a ismake= 1+%ismake%
if defined viminstallpath set /a ismake= 1+%ismake%
if ismake EQU 0 goto Install

type nul > netupvim.ini
if defined viminstallmode echo source = "%viminstallmode%" >>netupvim.ini
if defined viminstallpath echo target_dir = "%viminstallpath:\=/%" >>netupvim.ini

:Install
if %restore% EQU 1 goto Restore
call UPDATE.bat
goto EOF
:Restore
call RESTORE.bat
goto EOF

:EOF
endlocal

解説

  1. ダウンロードするファイル名、ダウンロード先などを設定する
  2. 重複してダウンロードしたり展開しないようにチェックをかける
  3. powershellを使ってgithubからzipをダウンロードする
  4. 展開
  5. 設定によって netupvim.ini を作る
  6. インストールをする

今回はnetupvimのプロキシ設定なんかは考慮してない
でも :MakeIni 周りに書き足せば対応できるので必要なら対応する
gitコマンドが使えるならvimrcのクローン周りも書いてしまえばvimのセットアップがはかどりそう

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?