[code-server+VSApp] 在iPad上使用VSCode
一直在用的是游戲本,太重了,非習武之人,而且?guī)С鋈ヒ膊环奖?br /> 于是這幾天買了藍牙鍵盤,配上 ipad 就是 macbook 了(錯亂)
碰巧沖浪時發(fā)現(xiàn) ipad 上也可以跑代碼(其實需要服務器),gkd!
好,開始羅干
運行環(huán)境
- ECS:阿里云
- 系統(tǒng):Ubuntu 16.04
- code-server 版本:3.2.0
- VSApp 版本:2.2
配置code-server
臨時買了阿里云 9.5 元包月的學生機 (沒錢)
先到 GitHub 上面下載 code-server 然后傳到服務器上,或者直接在服務器上執(zhí)行命令:
如果下載速度很慢的話可以掛代理,或者去 https://d.serctl.com/ 上扒(懶人福音)
之后解壓:
可以改一下名:
mv code-server-3.2.0-linux-x86_64 code-server運行:
cd code-server ./code-server推薦先看一遍參數(shù)表:
./code-server --help顯示類似于:
Usage: code-server [options] [path]Options--auth The type of authentication to use. [password, none]--cert Path to certificate. Generated if no path is provided.--cert-key Path to certificate key when using non-generated cert.--disable-updates Disable automatic updates.--disable-telemetry Disable telemetry.-h --help Show this output.--open Open in browser on startup. Does not work remotely.--bind-addr Address to bind to in host:port.--socket Path to a socket (bind-addr will be ignored).-v --version Display version information.--user-data-dir Path to the user data directory.--extensions-dir Path to the extensions directory.--list-extensions List installed VS Code extensions.--force Avoid prompts when installing VS Code extensions.--install-extension Install or update a VS Code extension by id or vsix.--uninstall-extension Uninstall a VS Code extension by id.--show-versions Show VS Code extension versions.--proxy-domain Domain used for proxying ports. -vvv --verbose Enable verbose logging.常用的運行方式:
export PASSWORD="114514" ./code-server --port 9999 --host 0.0.0.0 --auth password- –port 9999 指定端口,缺省時為 8080
- –host 0.0.0.0 允許公網訪問,缺省時為 127.0.0.1,只能本地訪問
- –auth password 指定訪問密碼,可通過 export 命令設置,參數(shù)為 none 時不啟用密碼
顯示類似于:
info code-server 3.2.0 fd36a99a4c78669970ebc4eb05768293b657716f info HTTP server listening on http://0.0.0.0:9999 info - Using custom password for authentication info - Not serving HTTPS info Automatic updates are enabled打開 Chrome 訪問“服務器公網IP:端口”,效果圖:
此時會話終止時 code-server 也隨即終止,掛到后臺運行:
nohup ./code-server --port 9999 --host 0.0.0.0 --auth password > test.log 2>&1 &上面的命令執(zhí)行后會返回一個 PID,結束運行只需要:
kill -9 PID如果忘記保存 PID,查詢方法:
ps aux | grep ./code-server但是每次都打一長串代碼不方便,寫成bash文件:
#start.sh export PASSWORD="114514" nohup ./code-server --port 9999 --host 0.0.0.0 --auth password > test.log 2>&1 & echo $! > save_pid.txt #shut.sh kill -9 'cat save_pid.txt'到這里為止,已經可以用瀏覽器食用 code-server 了
配置VSApp
App Store 搜索 VSApp 安裝,打開后可以選擇開發(fā)者提供的服務器(付費),也可以用自己的。
這里當然選擇 Self Hosted Server(不然為什么要折騰 code-server
依次填寫:
- code-server URL:服務器 IP :端口
- Instance password:–auth 命令設置的密碼
- Host:服務器 IP
- Username:登錄用戶名
- Port:SSH 端口(默認 22)
- Authentication:密碼或密鑰對(點擊 Setup key pair 設置)
保存以后就可以用 VSApp 訪問 code-server 了:
Enjoy it!
UPD:關于iOS端Safari無法訪問code-server(感謝@fresh_young_man)
把safari的web kit 全部打開,在高級設置里的實驗特性里
總結
以上是生活随笔為你收集整理的[code-server+VSApp] 在iPad上使用VSCode的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 12月6日云栖精选夜读:语音购票、刷脸进
- 下一篇: IOS 文件读写操作详解及简单实例