win10 terminal 配置

主题配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
// This file was initially generated by Windows Terminal 1.4.3243.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.

// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",

"defaultProfile": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",

// You can add more global application settings here.
// To learn more about global settings, visit https://aka.ms/terminal-global-settings

// If enabled, selections are automatically copied to your clipboard.
"copyOnSelect": false,

// If enabled, formatted data is also copied to your clipboard
"copyFormatting": false,

"tabWidthMode": "equal",

"theme": "light",

// A profile specifies a command to execute paired with information about how it should look and feel.
// Each one of them will appear in the 'New Tab' dropdown,
// and can be invoked from the commandline with `wt.exe -p xxx`
// To learn more about profiles, visit https://aka.ms/terminal-profile-settings
"profiles":
{
"defaults":
{
// Put settings here that you want to apply to all profiles.
"fontFace": "CaskaydiaCove NF",
"fontSize": 16,
"cursorShape": "filledBox",
},
"list":
[
{
"guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
"hidden": false,
"name": "PowerShell 7",
"source": "Windows.Terminal.PowershellCore",
"tabTitle": "PowerShell 7",

// morec
// 背景图片
"acrylicOpacity": 0.5,
"backgroundImage": "E:/picture/2020-12-18/wallhaven-o3d3w7.jpg",
"backgroundImageOpacity": 0.25,
"backgroundImagerStretchMode": "fill",
"useAcrylic": true,

"padding": "0, 0, 0, 0",
// 键入时窗口滚动到输入行
"snapOnInput": true,
// 打开时的目录
"startingDirectory": ".",
// tab标题
"tabTitle": "powershell",
// 使用acrylic
"useAcrylic": false,

//主题
"colorScheme": "Solarized Dark Higher Contrast",
},
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "PowerShell",
"commandline": "powershell.exe",
"tabTitle": "PowerShell",

// morec
// 背景图片
"acrylicOpacity": 0.25,
"backgroundImage": "E:/picture/2020-12-07/wallhaven-y87dxx.jpg",
"backgroundImageOpacity": 0.25,
"backgroundImagerStretchMode": "fill",

"padding": "0, 0, 0, 0",
// 键入时窗口滚动到输入行
"snapOnInput": true,
// 打开时的目录
"startingDirectory": ".",
// tab标题
"tabTitle": "powershell",
// 使用acrylic
"useAcrylic": false,

//主题
"colorScheme": "Cobalt Neon",
},
{
// Make changes here to the cmd.exe profile.
"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"name": "Command Prompt",
"commandline": "cmd.exe",
"hidden": false,
// more
"acrylicOpacity": 0.25,
"backgroundImage": "E:/picture/wallhaven-1kjqdw.jpg",
"backgroundImageOpacity": 0.25,
"backgroundImagerStretchMode": "fill",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%",
"tabTitle": "cmd",
"useAcrylic": false,

//主题
"colorScheme": "Thanatos Dark",
},
{
// 通过terminal连接服务器
"guid": "{B5F0BC97-C32E-67A0-97E1-6112A50DF336}",
"name": "aliyun",
"commandline": "ssh root@123.56.252.111",
"acrylicOpacity": 0.4,
"backgroundImage": "E:/picture/2020-12-18/wallhaven-6oq5lq.jpg",
"backgroundImageOpacity": 0.4,
"backgroundImagerStretchMode": "fill",
"padding": "0, 0, 0, 0",
"snapOnInput": true,
"startingDirectory": "%USERPROFILE%",
"tabTitle": "aliyun",
"useAcrylic": false,
"icon": "ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png", // 图标
//主题
"colorScheme": "Thanatos Dark",

},
{
"guid": "{db1d57fc-a9c1-4051-9677-f0232f905f60}",
"hidden": false,
"name": "Tencent Server",
"commandline": "ssh root@81.71.14.51",
"icon": "ms-appdata:///roaming/TencentServer.png",

// morec
// 背景图片
"acrylicOpacity": 0.5,
"backgroundImage": "E:/picture/2020-12-23/wallhaven-o3dvv9.jpg",
"backgroundImageOpacity": 0.25,
"backgroundImagerStretchMode": "fill",
"useAcrylic": true,

"padding": "0, 0, 0, 0",
// 键入时窗口滚动到输入行
"snapOnInput": true,
// 打开时的目录
"startingDirectory": ".",
// tab标题
"tabTitle": "powershell",
// 使用acrylic
"useAcrylic": false,

//主题
"colorScheme": "Thanatos Dark",
"cursorColor" : "#FFFFFF",
},
{
"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
"hidden": false,
"name": "Azure Cloud Shell",
"source": "Windows.Terminal.Azure"
},
]
},

// Add custom color schemes to this array.
// To learn more about color schemes, visit https://aka.ms/terminal-color-schemes
"schemes": [
{
"name": "Thanatos Dark",
"background" : "#1a2b3c",
"foreground" : "#e09887",
"selectionBackground": "#fef8ec",
"black": "#65737e",
"blue": "#0e9bd1",
"brightBlack": "#acacac",
"brightBlue": "#7899ba",
"brightCyan": "#0099ad",
"brightGreen": "#0de1b1",
"brightRed": "#d47186",
"brightWhite": "#fef8ec",
"brightYellow": "#d8cb32",
"brightPurple": "#ab43aa",
"purple": "#928ba6",
"cyan": "#008486",
"green": "#0099ad",
"red": "#ce4559",
"white": "#fef8ec",
"yellow": "#d8cb32"
},
{
"name": "Cobalt Neon",
"black": "#142631",
"red": "#ff2320",
"green": "#3ba5ff",
"yellow": "#e9e75c",
"blue": "#8ff586",
"purple": "#781aa0",
"cyan": "#8ff586",
"white": "#ba46b2",
"brightBlack": "#fff688",
"brightRed": "#d4312e",
"brightGreen": "#8ff586",
"brightYellow": "#e9f06d",
"brightBlue": "#3c7dd2",
"brightPurple": "#8230a7",
"brightCyan": "#6cbc67",
"brightWhite": "#8ff586",
"background": "#142838",
"foreground": "#8ff586"
},
{
"name": "Aurora",
"black": "#23262e",
"red": "#f0266f",
"green": "#8fd46d",
"yellow": "#ffe66d",
"blue": "#0321d7",
"purple": "#ee5d43",
"cyan": "#03d6b8",
"white": "#c74ded",
"brightBlack": "#292e38",
"brightRed": "#f92672",
"brightGreen": "#8fd46d",
"brightYellow": "#ffe66d",
"brightBlue": "#03d6b8",
"brightPurple": "#ee5d43",
"brightCyan": "#03d6b8",
"brightWhite": "#c74ded",
"background": "#23262e",
"foreground": "#ffca28"
},
{
"name": "FunForrest",
"black": "#000000",
"red": "#d6262b",
"green": "#919c00",
"yellow": "#be8a13",
"blue": "#4699a3",
"purple": "#8d4331",
"cyan": "#da8213",
"white": "#ddc265",
"brightBlack": "#7f6a55",
"brightRed": "#e55a1c",
"brightGreen": "#bfc65a",
"brightYellow": "#ffcb1b",
"brightBlue": "#7cc9cf",
"brightPurple": "#d26349",
"brightCyan": "#e6a96b",
"brightWhite": "#ffeaa3",
"background": "#251200",
"foreground": "#dec165"
},
{
"name": "Solarized Dark Higher Contrast",
"black": "#002831",
"red": "#d11c24",
"green": "#6cbe6c",
"yellow": "#a57706",
"blue": "#2176c7",
"purple": "#c61c6f",
"cyan": "#259286",
"white": "#eae3cb",
"brightBlack": "#006488",
"brightRed": "#f5163b",
"brightGreen": "#51ef84",
"brightYellow": "#b27e28",
"brightBlue": "#178ec8",
"brightPurple": "#e24d8e",
"brightCyan": "#00b39e",
"brightWhite": "#fcf4dc",
"background": "#142838",
"foreground": "#9cc2c3"
}



],

// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
{ "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
{ "command": "paste", "keys": "ctrl+v" },

// Press Ctrl+Shift+F to open the search box
{ "command": "find", "keys": "ctrl+shift+f" },

// Press Alt+Shift+D to open a new pane.
// - "split": "auto" makes this pane open in the direction that provides the most surface area.
// - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
// To learn more about panes, visit https://aka.ms/terminal-panes
{ "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
]
}

cmd

cmd

连接服务器

客户端生成ssh公私钥

ssh-keygen

本地ssh公钥追加到服务器

id_rsa.pub的内容复制到tmp.pub

1
2
3
4
5
6
cd ~
vi tmp.pub
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
cat tmp.pub >> .ssh/authorized_keys
rm tmp.pub

重启terminal

成功!

解决终端链接服务器长时间不操作卡死

在服务器中执行

1
2
3
4
5
6
7
8
9
10
vim /etc/ssh/sshd_config

ClientAliveInterval  60      // 每隔60S向客户端发送请求消息,并等待客户端响应
ClientAliveCountMax  10   // 客户端超过十次没响应,自动断开(即10分钟)

//重启sshd服务
//centos6
service ssh restart
//centos7
systemctl restart sshd

进入所在用户的.ssh目录,

root用户的目录在:/root/.ssh/
创建config文件
vim /root/.ssh/config
在文件中添加:
ServerAliveINterval 60(没写错,就是INterval,我也不知道为什么,)
保存退出,重新从终端通过ssh进入服务器后不会因为长时间操作断开。

加入这句之后,ssh客户端会每隔一段时间自动与ssh服务器通信一次,所以长时间操作不会断开。

terminal 添加右键

检查常量

1
2
3
echo %USERPROFILE%

echo %LOCALAPPDATA%

获取图标

创建Terminal文件夹

1
mkdir "%USERPROFILE%\AppData\Local\Terminal"

保存这个 图标

添加注册表文件

新建一个文件 new.reg

1
2
3
4
5
6
7
8
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt]
@="Windows Terminal here"
"Icon"="%USERPROFILE%\\AppData\\Local\\Terminal\\terminal.ico"

[HKEY_CLASSES_ROOT\Directory\Background\shell\wt\command]
@="C:\\Users\\[你的电脑用户名!你的电脑用名!]\\AppData\\Local\\Microsoft\\WindowsApps\\wt.exe"
  • @后面的[]改成电脑的用户名
  • 如果第一步USERPROFILE没有东西打印出来,那么这里的USERPROFILE也改成C:\Users\你的用户名
  • 第5行时图标保存的地址

执行reg文件,可以发现右键多了一个windows termianl here

当前目录

在配置文件中添加或修改

1
2
// 打开时的目录
"startingDirectory": ".",

这样也有一个缺点,直接打开termianl时目录为C:\Windows\System32目前没有解决方法

PowerShell主题

参考

安装oh-my-posh主题

在terminal输入

1
2
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser

输入Y同意安装

更新配置文件

terminal输入$PROFILE

得到当前电脑的powershell_profile文件

1
2
3
PS C:\Windows\System32> $PROFILE
C:\Users\64371\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
PS C:\Windows\System32>

继续输入

1
2
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE

在打开的文件夹中添加

1
2
3
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Honukai

Set-Theme Honukai是主题设置,其他可选主题

1
Agnoster、Avit、Darkblood、Fish、Honukai、Paradox、Sorin、tehrob

更新配置

输入你用$PROFILE得到的路径

1
C:\Users\64371\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

有些主题的样式可能会有些小空格,这时因为字体不支持poweline,推荐选择Hack NF字体,支持编程连字和poweline字形

下载链接

我的样式

powershell 5

poweshell5

power shell 7

powershell7

Centos-terminal 主题

参考

查看系统当前shell

1
echo $SHELL

结果

1
/bin/bash

查看/bin下是否有zsh

1
2
3
4
5
6
7
8
9
10
cat /etc/shells
**********************************************
返回的结果是:
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
PS.默认没有安装zsh

安装zsh

1
sudo yum install -y zsh

在/bin下查看

1
2
3
4
5
6
7
/bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/zsh

zsh设置成默认shell

1
chsh -s /bin/zsh

修改zsh为默认shell需要将以前在~/.bashrc中的设置,复制到~/.zshrc

安装oh-my-zsh

需要先装git

1
sudo yum install git

修改host

1
vim /etc/hosts

添加

1
199.232.28.133 raw.githubusercontent.com

下载

1
sudo wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

配置主题

主题

选择一款主题,修改~/.zshrc

1
vim ~/.zshrc

ZSH_THEME更改为选择的主题 jonathan

更新配置

source ~/.zshrc

重启

reboot

我的样式

aliyun Centos7

阿里云

tencent Centos7

腾讯云

管理员

powershell中执行

1
PowerShell -Command "Set-ExecutionPolicy RemoteSigned -scope Process; iwr -useb https://raw.githubusercontent.com/gerardog/gsudo/master/installgsudo.ps1 | iex"

安装过程会询问你是否打算使用sudo作为gsudo的别名,这里可以根据个人需要进行选择。
运行结尾显示Done即表明安装完成

安装完成后,在setting.json中添加list

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"hidden": false,
"name": "PowerShell Administra",
"commandline": "sudo.exe powershell.exe",
"tabTitle": "PowerShell Administra",

// morec
// 背景图片
"acrylicOpacity": 0.25,
"backgroundImage": "E:/picture/2020-12-07/wallhaven-y87dxx.jpg",
"backgroundImageOpacity": 0.25,
"backgroundImagerStretchMode": "fill",

"padding": "0, 0, 0, 0",
// 键入时窗口滚动到输入行
"snapOnInput": true,
// 打开时的目录
"startingDirectory": ".",
// tab标题
"tabTitle": "powershell",
// 使用acrylic
"useAcrylic": false,

//主题
"colorScheme": "Cobalt Neon",
},

在普通的powershell中执行sudo,也可以升级成管理员

---------Thanks for your attention---------