整理目录

This commit is contained in:
2024-03-22 17:42:41 +08:00
parent 5a4efad893
commit fab9914f39
158 changed files with 158 additions and 84 deletions

View File

@ -0,0 +1,42 @@
---
title: Windows10%20WSL2 安装 尝鲜
---
> 2019 年 6 月 13 日,windows 发布了 Build 18917 预览版,值得一提的是,Windows Subsystem for Linux 2(WSL2)也可以使用了,在将现在的系统升级到 18917 后(需要参与预览版计划),就迫不及待的想尝试了
![](img/Windows10%20WSL2.assets/a16ed8dbd137815b2577650ac5e8889a.png)
## WSL2 安装开启
安装 wsl2 需要开启`Virtual Machine Platform`
![](img/Windows10%20WSL2.assets/2fd49865293c12aaa0b550b0a35ec143.png)
或者,管理员 PowerShell 运行:
`Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform`
然后 PowerShell 管理员运行:
`wsl --set-default-version 2` 设置默认为 wsl2
`wsl --set-version Debian 2`设置某个发行版为 wsl2(竟然可以切换,不错)
(我用的是 CMD 管理员也是可以的,官方 blog 说的是 PowerShell)
![](img/Windows10%20WSL2.assets/89cb491e39c43528434c324ad6f1f372.png)
![](img/Windows10%20WSL2.assets/ecb0ec1c0e6b8ea8ba3b34a23d81f6f4.png)
之后可以使用`wsl --list --verbose`查看使用的 wsl 版本
然后去 Microsoft Store 找 linux 就行了
![](img/Windows10%20WSL2.assets/f8209cd993dd3254af22c3cfa415859c.png)
![](img/Windows10%20WSL2.assets/b54c5fa49baa561e0942c66730c1b577.png)
成了,等下去试试装 docker,然后我就可以抛弃现在的 desktop for docker 了 233,看外表还看不出啥
![](img/Windows10%20WSL2.assets/f1c6ec7ad6baee042655bb366aface0e.png)
### 网络
![](img/Windows10%20WSL2.assets/806f10f788a514951054f68f01af0254.png)
我是这样做的,ifconfig 获取 ip

View File

@ -0,0 +1,145 @@
---
title: Windows装杯且实用的终端配置 - WindowsTerminal+PowerShell优化
---
> 作为一名开发人员,经常需要在终端输入一些命令和连接 ssh 啥的,之前一直是使用的 git bash,作为我的默认终端,和使用 xshell 来连接 ssh.在前几日配置,我配置 wsl2+oh-my-zsh 的时候无意间看见了一个 oh-my-posh 的项目,于是就想能不能将 Windows 的终端也像 Linux 配置得那么强大.
> 本篇文章也并不是非常专业的配置,更多的是作为一个分享.现在我已经几乎不再使用 xshell 和 git bash 了.
## Windows Terminal
> [Windows 终端](https://docs.microsoft.com/zh-cn/windows/terminal/)是一个面向命令行工具和 shell如命令提示符、PowerShell 和适用于 Linux 的 Windows 子系统 (WSL))用户的新式终端应用程序。 它的主要功能包括多个选项卡、窗格、Unicode 和 UTF-8 字符支持、GPU 加速文本呈现引擎,你还可用它来创建你自己的主题并自定义文本、颜色、背景和快捷方式。(来自官网介绍)
对于这款终端这里也不做更多的介绍了,安装这款终端很方便,已经发布在了 Microsoft Store,直接搜索安装就可以了.
然后是做一些样式的配置,虽然我觉得默认的已经挺好了,这里推荐一个 Theme 的网站,可以选一款自己喜欢的,当然也可以自己配置属于自己的主题:[Andromeda](https://windowsterminalthemes.dev/?theme=3024%20Night)
配置片段:
```json
"profiles": {
"defaults": {
"name": "Andromeda",
"black": "#000000",
"red": "#cd3131",
"green": "#05bc79",
"yellow": "#e5e512",
"blue": "#2472c8",
"purple": "#bc3fbc",
"cyan": "#0fa8cd",
"white": "#e5e5e5",
"brightBlack": "#666666",
"brightRed": "#cd3131",
"brightGreen": "#05bc79",
"brightYellow": "#e5e512",
"brightBlue": "#2472c8",
"brightPurple": "#bc3fbc",
"brightCyan": "#0fa8cd",
"brightWhite": "#e5e5e5",
"background": "#262a33",
"foreground": "#e5e5e5"
},
```
### 连接 SSH
对于连接 SSH,我们可以直接在 Windows Terminal 里配置一列,就像下面这样:
```json
{
"guid": "{3a2e18e6-ee47-ff96-582b-adb64c63bf14}",
"hidden": false,
"name": "树莓派",
"commandline": "ssh root@192.168.1.1"
}
```
缺点是不能记住密码,解决方案是配置公私密钥,但是我的密码足够简单且是内网访问...就暂未操作- -...对于复杂的还是使用 xshell,有时间配置免密登录,完全抛弃 xshell.
## 优化 PowerShell
> 分两步,使用[oh-my-posh](https://github.com/JanDeDobbeleer/oh-my-posh)做美化,然后安装一些插件增强功能.虽然还是做不到 linux 下的 zsh 那么强大,插件好少,但是至少比原来的好多了,也足够我用.
### 安装 oh-my-posh
也没那么难,跟着官方文档来就完事了.记得使用管理员权限打开终端.
![](img/WindowsTerminal+PowerShell优化.assets/wp_editor_md_d11bd59f2568cb41a8e78c968121376b.jpg)
速度感觉很慢....耐心等待
```bash
Set-ExecutionPolicy Unrestricted
Import-Module PowerShellGet
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
```
输入下面命令,编辑配置
```bash
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE
```
在弹出的编辑框里面输入下面的内容,主题可以挑一个你喜欢的:[themes](https://github.com/JanDeDobbeleer/oh-my-posh#themes),然后保存
```bash
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
```
再重新打开你的终端,就完成了,但是这时候还有一些乱码,我们需要安装字体去解决:[nerd-fonts](https://github.com/ryanoasis/nerd-fonts)
![](img/WindowsTerminal+PowerShell优化.assets/wp_editor_md_faf324c370cf870d437c9d5b7ca03761.jpg)
我们去 release 页面下载这个字体,当然也可以自己选择,主要是终端使用到的一些图标字符
![](img/WindowsTerminal+PowerShell优化.assets/wp_editor_md_aba5c48ea60c885a43ceeebdec7a8b47.jpg)
下载完成之后,我随便找一个,实在太多了,不知道怎么选择,也可以根据[字体项目的文档](https://github.com/ryanoasis/nerd-fonts/blob/master/readme_cn.md),全部安装下来去挑,不过个人感觉看不出太多变化,我选择了下面这个进行安装:MesloLGS Nerd Font(Meslo LG S Regular Nerd Font Complete.ttf)
![](img/WindowsTerminal+PowerShell优化.assets/wp_editor_md_3ac624d1db855ba8320b7f907c32136a.jpg)
然后编辑 WindowsTerminal,使用这个字体就可以了.另外多说一句,`Azure Cloud Shell`无法删除,可以将`hidden`设置为 true 隐藏.
![](img/WindowsTerminal+PowerShell优化.assets/wp_editor_md_c0f8af9bb7b08cb40737aff02930f26a.jpg)
进入一些 git 目录就有下面这种效果啦
![](img/WindowsTerminal+PowerShell优化.assets/wp_editor_md_8d9c78924bc90e86f92fb981679c2aca.jpg)
### PSReadLine
> PS 在此之前,每次写命令,都要一个一个的打出来,装了之后输入一部分内容就可以自动提示剩余的内容,按下方向右键就可以完成命令.
管理员模式下输入下面的命令
```bash
Install-module PSReadline -Scope CurrentUser
```
然后输入下面命令,编辑配置
```bash
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE
```
添加下面内容:
```bash
# PSReadLine
Import-Module PSReadLine
# Enable Prediction History
Set-PSReadLineOption -PredictionSource History
# Advanced Autocompletion for arrow keys
Set-PSReadlineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadlineKeyHandler -Key DownArrow -Function HistorySearchForward
```
完成:
![](img/WindowsTerminal+PowerShell优化.assets/wp_editor_md_722ee058838b8f7139bff303f7f91c92.jpg)

View File

@ -0,0 +1,4 @@
{
"label": "工具资源",
"position": 5
}

View File

@ -0,0 +1,44 @@
---
title: 从根本上解决鼠标手,chrome 插件"Vimium"分享
---
> 安利一个 chrome 插件,`Vimium`,全键盘上网(不用鼠标就不会出现鼠标手了啦\~),再想象一下电影里面啪啪啪啪那种敲键盘的感觉,so cool?~
Chrome 商店安装地址: https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
github 开源地址: https://github.com/philc/vimium
## 常用命令
> 命令其实挺多的,我先写出我比较常用的一些命令,也能够覆盖到大部分使用场景了(全部一下子也记不住,记住了也没办法熟练的使用)
- 页面滚动命令: h(左)j(下)k(上)l(右)
- 页面滚动命令 2: gg(滚动到最顶部) shift+g(其实就是大写的`G`,shift 大小写转换而已) u(相当于 PgUp,向上滚动) d(向下滚动).这个命令挺好用的
- 左右切换 tab: Shift+j/J(左边 tab) shift+k/K(右边 tab)
- tab 切换命令 2: shift+t/T,会弹出一个框可以选择 tab 进行跳转
- 前进/后退:shift+h/H(后退) shift+l/L(前进)
- 关闭/恢复页面: x(关闭当前页面) shift+x(恢复上一个关闭的页面)
- 打开新页面命令: o(当前页面打开) shift+o/O(新页面打开) b(当前页面) shift+b/B(新页面打开),o 是会在历史记录/书签栏/关键字搜索,b 是在书签栏中搜索.这个命令我也很喜欢,直接的替换了我原来的一个书签管理工具,因为记录得实在是太多了...自己都找不到.
- 点击链接: f(当前页面),shift+f/F(新页面打开).按下后会有很多链接的指示,按照指示输入字母就可以点击链接了.
- tab 切换命令 2: g0(切换到第一个 tab) g$(shift+4)(切换到最后一个 tab) ^(shift+6)(切换到上一个打开的 tab)
## 进阶命令
> 还有一些命令,如果能熟练就更好了,虽然我自己也用得很少,因为有浏览器自己的快捷键(ctrl+cv,复制粘贴),或者我觉得没有鼠标习惯/方便,我也不是很熟练,还是习惯的去动鼠标- -...
插件和 vim 一样,有很多模式,按 esc 退出当前模式,在右下角会有提示
- v 进入视图模式,输入之后会发现有一个地方被选中,这时按 hjkl 可以进行移动操作
- y 复制选中的文本
- gi 选中输入框,进行输入,按 tab 可以进行切换
- ma 可以给当前位置做一个标记
- \`a 可以快速翻到标记位置(小写是当前页面的标记,大写是全浏览器的标记),一个超级方便的指令!
- yy 复制当前页面的链接,也是一个很方便的指令
## 其它命令
> 如果你记住了以上命令,已经可以完全的摆脱鼠标了(但是有些地方的操作我觉得鼠标更方便一点,或许是我已经习惯鼠标了吧),剩下的就是去熟练的使用了
- ? 打开帮助(但是好像有些命令没有写),万一忘记了,可以看看命令记一下,也会比我这里的更全,还有 wiki:https://github.com/philc/vimium/wiki
- / 进入搜索模式(感觉鸡肋...我喜欢 ctrl+f)
- n/N 进入搜索模式后查找下/上一个

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 443 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,79 @@
---
title: vscode web版本搭建
---
> 今天拿 ipad 看书的时候,想到之前看到的一个文章说可以在浏览器上使用 vscode而且看书的时候牵扯到一些函数的参数和具体描述无法知道(难查文档),就想能不能整一个这样的环境,一边看书也可以一边去**浅度**的了解里面使用的方法,也可以写代码进行调试.
## 准备
一台服务器,我在 [https://www.vultr.com/?ref=7107762](https://www.vultr.com/?ref=7107762) 购买了一台服务器,准备作为环境。(感觉国外的好一点,对于拉包速度之类)
链接服务器的工具,我这里使用的 putty,服务器系统是 centos7
## 安装环境
> 官方说得好模糊....踩了好多坑,也许是我系统太干净的原因?
[https://github.com/microsoft/vscode/wiki/How-to-Contribute](https://github.com/microsoft/vscode/wiki/How-to-Contribute)
```bash
# 装好git curl 之类的必须品
yum install git curl gcc gcc-c++ libX11-devel.x86_64 libxkbfile-devel.x86_64 libsecret-devel sqlite-devel zlib-devel bzip2-devel
# 安装nodejs和yarn
curl --silent --location https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
curl --silent --location https://rpm.nodesource.com/setup_10.x | bash -
sudo yum install -y nodejs
sudo yum install -y yarn
# 安装python27
wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tgz
tar -zxvf Python-2.7.17.tgz
cd Python-2.7.17
./configure
make && make install
# 克隆vscode仓库
cd ..
git clone https://github.com/microsoft/vscode.git
cd vscode
firewall-cmd --zone=public --add-port=8080/tcp --permanent
systemctl restart firewalld
npm install -g node-gyp
# 按照官方的来的,但是好像有问题?有一些地址是localhost,而且文件打不开,可以看下面的方法
git checkout 1.40.1
yarn
yarn watch
yarn web
```
然后我就开始使用另外一个项目,命令和上面的一样,除了上面四行 https://github.com/cdr/code-server ,注意上方`git checkout v1.40.1` 要换成其它版本,如:`git checkout v1.39.2` 见:https://github.com/cdr/code-server/issues/1170 (可能以后会支持吧)
```bash
git checkout 1.39.2
yarn
git clone https://github.com/cdr/code-server src/vs/server
cd src/vs/server
yarn
yarn patch:apply
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
yarn watch
yarn start
```
(中间因为服务器太辣鸡了...build 内存不够,然后分配了 4g 虚拟内存解决了...过程中非常卡,服务器都连不上)
完成之后访问 http://ip:8080 就可以用了,`code-server`会要你输入密码,yarn start 会获得
![](./img/809d7db3ac159d37b1ca4c9f69c61808.png)
![](./img/95c8c1c596bf5a22c26096a7fed4e1db.png)
感觉要台网络好的服务器比较好....(我然后装了 bbr 感觉好多了)
可以安装扩展,但是好像装一次扩展然后要重新加载(然后又等很久)
想像体验:
![](./img/tWrqlGeKcOEJe0D.png)
实际体验:
我枯了,bug 比较多,Terminal 跑不起来,代码也不能运行,单单的平板操作很不好(是我需要外接键鼠么?).我觉得还不如用 duet 来分屏.
不过还是很期待以后的版本的.

View File

@ -0,0 +1,79 @@
---
title: 一次树莓派系统安装记录
---
> 暑假了,给树莓派重新弄一次系统,这回是 pi3b+,上次写 swoole 用的是 pizero,这回给 pi3 重新刷一个,然后再安装 swoole
## 准备
- 网线 \* 1
- micro usb \* 1
- pi3b+ \* 1
- 读卡器 \* 1
- micro sd 卡 \* 1
## 镜像制作
从官网下载镜像 [https://www.raspberrypi.org/downloads/](https://www.raspberrypi.org/downloads/)
有挺多的,我选择的是这个 [https://www.raspberrypi.org/downloads/raspbian/](https://www.raspberrypi.org/downloads/raspbian/)
![](img/%E4%B8%80%E6%AC%A1%E6%A0%91%E8%8E%93%E6%B4%BE%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E8%AE%B0%E5%BD%95.assets/TIM%E6%88%AA%E5%9B%BE20180708224929-300x224.png)
带桌面和一些程序
下载好镜像之后,还需要一个制作工具:win32diskimager,百度下载吧- -推荐绿色版,这些小东西我是不喜欢安装
然后打开,选好我们的镜像和读卡器插入的那个盘符就好了
![](img/%E4%B8%80%E6%AC%A1%E6%A0%91%E8%8E%93%E6%B4%BE%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E8%AE%B0%E5%BD%95.assets/TIM%E6%88%AA%E5%9B%BE20180708222459-300x152.png)
我们前面下载的是一个 zip 文件,我们解压它,然后就得到了一个 img 文件,用这个工具写入 突然 1 个多 g 就变成了 4 个多 g
## 配置
### 开启 ssh
我们又没显示屏...(如果你有转化的话可以直接插键盘鼠标操作....)没 ssh 干不了活啊,在前面镜像制作完毕后,我们会多一个 **boot:盘符** 的磁盘(我做了几次都没有出现,后来重启一下电脑就好了...)
![](img/%E4%B8%80%E6%AC%A1%E6%A0%91%E8%8E%93%E6%B4%BE%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E8%AE%B0%E5%BD%95.assets/TIM%E6%88%AA%E5%9B%BE20180708233438-300x169.png)
然后在里面新建一个 ssh 的文件,插上网线,电源,sd 卡,如果红灯绿灯都亮了就代表成功了
在路由里面找到了我们的 pi 的 ip(最好分配一个 ip),然后连上 ssh,还有什么好怕的?
![](img/%E4%B8%80%E6%AC%A1%E6%A0%91%E8%8E%93%E6%B4%BE%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E8%AE%B0%E5%BD%95.assets/TIM%E6%88%AA%E5%9B%BE20180708233654-300x46.png)
![](img/%E4%B8%80%E6%AC%A1%E6%A0%91%E8%8E%93%E6%B4%BE%E7%B3%BB%E7%BB%9F%E5%AE%89%E8%A3%85%E8%AE%B0%E5%BD%95.assets/TIM%E6%88%AA%E5%9B%BE20180708234052-300x95.png)
这里连接的账号和密码是默认的:
账号:`pi` 密码:`piraspberry`
### 初始化配置
要进行一些密码的修改
ssh 中输入,进入一个面板
```
sudo raspi-config
```
#### 配置密码
选中`change user password`,然后会提示你输入新的密码
#### 开启 VNC
选中`Interfacing Options`选中`VNC`开启
#### 更改 root 密码和解锁 root
退回到之前的 ssh 界面,输入
```
sudo passwd root
sudo passwd --unlock root
```
到这里就完成了,之后可以直接用 vnc viewer 连接操作