Xshell配色转WindowsTerminal配色

2024-01-12 12:40

本文主要是介绍Xshell配色转WindowsTerminal配色,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1. 本文目标

Xshell中的配色方案迁移到WindowsTerminal中使用。

  • 将Xshell配色方案导出
  • 更改字符集为UTF-8
  • 通过Java程序将Xshell配色方案转变成Windows Terminal配色方案
  • 配置Windows Terminal

2. 操作步骤

2.1 导出Xshell配色

在Xshell菜单栏中依次点击工具->配色方案,会弹出选择配色方案窗口。在窗口中选择(按住Ctrl可以多选)想要导出的配色方案,然后点击导出按钮,本文以导出New BlackNew WhiteXTerm为例,如下图所示:
在这里插入图片描述
选择要导出的目录,本文以D://data/为例,文件名为ColorSchemes.xcs
在这里插入图片描述

2.2 更改字符集为UTF-8

Xshell6导出的配色方案默认是UCS-2 Little Endian编码,Java:StandardCharsets.UTF_16LE

本文将采用UTF-8进行解析,所以需要将字符集改为UTF-8,使用Notepad++打开在菜单栏中点击编码->使用UTF-8编码,然后点击保存按钮。
在这里插入图片描述

2.3 配色方案转换

需要调整的地方为导出配色方案的路径,本例为D:\data\ColorSchemes.xcs

package terminal;import com.alibaba.fastjson.JSON;import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;/*** Xshell配色转WindowsTerminal配色** @author faith.huan 2020-01-31*/
public class ColorXshellToWinTerminal {public static void main(String[] args) throws IOException {InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream("D:\\data\\ColorSchemes.xcs"), StandardCharsets.UTF_8);Map<String, Map<String, String>> map = new HashMap<>(300);BufferedReader reader = new BufferedReader(inputStreamReader);String line = reader.readLine();String key = "";while (line != null) {// System.out.println("line = " + line);if (line.startsWith("[")) {key = line.substring(1, line.length() - 1);// System.out.println(key);} else {String[] split = line.split("=");if (!"Names".equals(key) && split.length == 2) {String fieldName = fieldMap.get(split[0]);if (fieldName != null) {String fieldValue = "#" + split[1];if (map.containsKey(key)) {map.get(key).put(fieldName, fieldValue);} else {Map<String, String> m = new TreeMap<>(new FieldComparator());m.put("name", key);m.put(fieldName, fieldValue);map.put(key, m);}}}}line = reader.readLine();}System.out.println(JSON.toJSONString(map.values(), true));}private static Map<String, String> fieldMap = new HashMap<>();static {/** 定义Xshell配色字段与WinTerminal配色字段映射关系*/fieldMap.put("text", "foreground");fieldMap.put("background", "background");fieldMap.put("black", "black");fieldMap.put("black(bold)", "brightBlack");fieldMap.put("red", "red");fieldMap.put("red(bold)", "brightRed");fieldMap.put("green", "green");fieldMap.put("green(bold)", "brightGreen");fieldMap.put("yellow", "yellow");fieldMap.put("yellow(bold)", "brightYellow");fieldMap.put("blue", "blue");fieldMap.put("blue(bold)", "brightBlue");fieldMap.put("magenta", "purple");fieldMap.put("magenta(bold)", "brightPurple");fieldMap.put("cyan", "cyan");fieldMap.put("cyan(bold)", "brightCyan");fieldMap.put("white", "white");fieldMap.put("white(bold)", "brightWhite");fieldMap.put("text(bold)", null);fieldMap.put(null, null);}/*** 控制输出的Window Terminal 配色方案字段排序*/static class FieldComparator implements Comparator<String> {private Map<String, Integer> orderMap = new HashMap<>();FieldComparator() {orderMap.put("name", 1);orderMap.put("foreground", 2);orderMap.put("background", 3);orderMap.put("black", 4);orderMap.put("red", 5);orderMap.put("green", 6);orderMap.put("yellow", 7);orderMap.put("blue", 8);orderMap.put("purple", 9);orderMap.put("cyan", 10);orderMap.put("white", 11);orderMap.put("brightBlack", 12);orderMap.put("brightRed", 13);orderMap.put("brightGreen", 14);orderMap.put("brightYellow", 15);orderMap.put("brightBlue", 16);orderMap.put("brightPurple", 17);orderMap.put("brightCyan", 18);orderMap.put("brightWhite", 19);}@Overridepublic int compare(String o1, String o2) {return orderMap.get(o1).compareTo(orderMap.get(o2));}}}

运行上面的Java代码会在控制台中输出如下json内容

[{"name":"XTerm","foreground":"#e5e5e5","background":"#002B36","black":"#000000","red":"#bb0000","green":"#006400","yellow":"#c8af00","blue":"#1e90f5","purple":"#bb00bb","cyan":"#00cdcd","white":"#ebebeb","brightBlack":"#555555","brightRed":"#ff5555","brightGreen":"#55ff55","brightYellow":"#fff555","brightBlue":"#50beff","brightPurple":"#ff55ff","brightCyan":"#55ffff","brightWhite":"#ffffff"
},{"name":"New White","foreground":"#292929","background":"#ffffff","black":"#36342e","red":"#a56434","green":"#008000","yellow":"#999606","blue":"#0000cc","purple":"#7b5175","cyan":"#00a2c4","white":"#cfd8d3","brightBlack":"#535755","brightRed":"#cf9e72","brightGreen":"#1cc470","brightYellow":"#e2e234","brightBlue":"#2929ef","brightPurple":"#a97ead","brightCyan":"#50ebfc","brightWhite":"#eceeee"
},{"name":"New Black","foreground":"#f2f2f2","background":"#242424","black":"#36342e","red":"#a56434","green":"#008000","yellow":"#999606","blue":"#4646ff","purple":"#7b5175","cyan":"#00a2c4","white":"#cfd8d3","brightBlack":"#535755","brightRed":"#cf9e72","brightGreen":"#1cc470","brightYellow":"#e2e234","brightBlue":"#6f6ff4","brightPurple":"#a97ead","brightCyan":"#50ebfc","brightWhite":"#eceeee"
}]

2.4 配置Windows Terminal

依次点击**﹀**->Settings,然后选择一个文本编辑器(此处使用Notepad++)打开配置文件文件。在这里插入图片描述
将上文生成的json数组内容(不包括开始符[,结束符]),复制到刚才打开的配置文件profiles.json中的"schemes": [],段的中括号内,如下所示。

    "schemes": [{"name":"XTerm","foreground":"#e5e5e5","background":"#002B36","black":"#000000","red":"#bb0000","green":"#006400","yellow":"#c8af00","blue":"#1e90f5","purple":"#bb00bb","cyan":"#00cdcd","white":"#ebebeb","brightBlack":"#555555","brightRed":"#ff5555","brightGreen":"#55ff55","brightYellow":"#fff555","brightBlue":"#50beff","brightPurple":"#ff55ff","brightCyan":"#55ffff","brightWhite":"#ffffff"},{"name":"New White","foreground":"#292929","background":"#ffffff","black":"#36342e","red":"#a56434","green":"#008000","yellow":"#999606","blue":"#0000cc","purple":"#7b5175","cyan":"#00a2c4","white":"#cfd8d3","brightBlack":"#535755","brightRed":"#cf9e72","brightGreen":"#1cc470","brightYellow":"#e2e234","brightBlue":"#2929ef","brightPurple":"#a97ead","brightCyan":"#50ebfc","brightWhite":"#eceeee"},{"name":"New Black","foreground":"#f2f2f2","background":"#242424","black":"#36342e","red":"#a56434","green":"#008000","yellow":"#999606","blue":"#4646ff","purple":"#7b5175","cyan":"#00a2c4","white":"#cfd8d3","brightBlack":"#535755","brightRed":"#cf9e72","brightGreen":"#1cc470","brightYellow":"#e2e234","brightBlue":"#6f6ff4","brightPurple":"#a97ead","brightCyan":"#50ebfc","brightWhite":"#eceeee"}],

启用XTerm配色方案,以ubuntu18.04为例,使用colorScheme指定配色方案XTerm

   "profiles":[{"guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}","hidden": false,"name": "Ubuntu-18.04","source": "Windows.Terminal.Wsl","colorScheme": "XTerm","icon":"D://javaDev/pic/u18.ico","startingDirectory" : "//wsl$/Ubuntu-18.04/home/faith"},...]        

3. 配色展示

3.1 XTerm配色

在这里插入图片描述

3.1 New White配色

在这里插入图片描述

3.3 New Black配色

在这里插入图片描述


图标下载地址:https://www.easyicon.net/ ,Tab上的图标下载32*32的即可,太大会模糊
完整profiles.json

// 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": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}","copyOnSelect": true,"profiles":[{"guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}","hidden": false,"name": "Ubuntu-18.04","source": "Windows.Terminal.Wsl","colorScheme": "XTerm","icon":"D://javaDev/pic/u18.ico","startingDirectory" : "//wsl$/Ubuntu-18.04/home/faith"},{"guid": "{6f9994f0-4403-5e85-9cce-98e5da3839bb}","hidden": false,"name": "Ubuntu-16.04","source": "Windows.Terminal.Wsl","colorScheme": "XTerm","icon": "D://JavaDev/pic/u16.ico","startingDirectory" : "//wsl$/Ubuntu-16.04/home/faith"},{// Make changes here to the powershell.exe profile"guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}","name": "Windows PowerShell","commandline": "powershell.exe","hidden": false},{// Make changes here to the cmd.exe profile"guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}","name": "cmd","commandline": "cmd.exe","hidden": false},{"guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}","hidden": true,"name": "Azure Cloud Shell","source": "Windows.Terminal.Azure"}],// Add custom color schemes to this array"schemes": [{"name":"XTerm","foreground":"#e5e5e5","background":"#002B36","black":"#000000","red":"#bb0000","green":"#006400","yellow":"#c8af00","blue":"#1e90f5","purple":"#bb00bb","cyan":"#00cdcd","white":"#ebebeb","brightBlack":"#555555","brightRed":"#ff5555","brightGreen":"#55ff55","brightYellow":"#fff555","brightBlue":"#50beff","brightPurple":"#ff55ff","brightCyan":"#55ffff","brightWhite":"#ffffff"},{"name":"New White","foreground":"#292929","background":"#ffffff","black":"#36342e","red":"#a56434","green":"#008000","yellow":"#999606","blue":"#0000cc","purple":"#7b5175","cyan":"#00a2c4","white":"#cfd8d3","brightBlack":"#535755","brightRed":"#cf9e72","brightGreen":"#1cc470","brightYellow":"#e2e234","brightBlue":"#2929ef","brightPurple":"#a97ead","brightCyan":"#50ebfc","brightWhite":"#eceeee"},{"name":"New Black","foreground":"#f2f2f2","background":"#242424","black":"#36342e","red":"#a56434","green":"#008000","yellow":"#999606","blue":"#4646ff","purple":"#7b5175","cyan":"#00a2c4","white":"#cfd8d3","brightBlack":"#535755","brightRed":"#cf9e72","brightGreen":"#1cc470","brightYellow":"#e2e234","brightBlue":"#6f6ff4","brightPurple":"#a97ead","brightCyan":"#50ebfc","brightWhite":"#eceeee"}],// Add any keybinding overrides to this array.// To unbind a default keybinding, set the command to "unbound""keybindings": []
}

这篇关于Xshell配色转WindowsTerminal配色的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/597905

相关文章

Xshell远程连接失败以及解决方案

《Xshell远程连接失败以及解决方案》本文介绍了在Windows11家庭版和CentOS系统中解决Xshell无法连接远程服务器问题的步骤,在Windows11家庭版中,需要通过设置添加SSH功能并... 目录一.问题描述二.原因分析及解决办法2.1添加ssh功能2.2 在Windows中开启ssh服务2

【MobaXterm 远程连接工具】Windows下有没有xshell的更好的替代品?

每次间隔一段时间,xshell 总是提醒需要更新,很烦,点更新又没有用。 xshell 官方下载地址: https://xshell.en.softonic.com/ 本文要隆重推出一款集万千于一身的全能型终端神器——MobaXterm!这款神器是我师傅介绍给我的,在我第一次使用它的时候,就深深爱上它了,真的是相见恨晚,从此一发不不可收拾,自己电脑,公司电脑全部都安上了这款神器。 先说说这款

Linux 如何在 vi 里搜索关键字(Xshell)

这里就废话少说 第一种直接 如果第一种不行就第二种 找到关键字后按上下左右的上然后按y一直按n是一直往上查找 反之按下键然后按n是往下查找

【windows实用工具一】tftpd32+Xshell

1. tftpd-tftp服务搭建 今天推荐一款非常好用的tftp服务器搭建工具Tftpd32,更高级的功能不需要知道,除非你有特殊需求,自行研究,这个工具能够快快速搭建一个tftp服务器,这就够了 1.1 下载地址 网上下载路径很多,搜索tftpd32即可,软件安装包不大,不到1M 1.2 使用方法 打开后界面如下,默认界面即为Tftp Server: Current Direc

linux~~目录结构远程登录教程(xshell+xftp)

目录 1.目录结构 2.远程登录xshell 2.1所需工具 2.2了解虚拟机IP 2.3查看是否正常连接 2.4xshell进行连接 3.文件传输xftp7 3.1xftp6安装 3.2相关设置 3.3效果展示 3.4文件之间的传输过程 1.目录结构 bin目录里面主要存放这个我们经常使用的指令,例如这个cd进行目录切换的指令,随着我们学习的深入,我

ggplot2高效实用指南 (可视化脚本、工具、套路、配色)

作者:严涛 浙江大学作物遗传育种在读研究生(生物信息学方向)伪码农,R语言爱好者,爱开源 ggplot2学习笔记之图形排列 R包ggseqlogo |绘制序列分析图 编者按:数据可视化是解析、理解和展示数据不可缺少的一部分。炫或不炫看个人喜好和功底,能否达意是最基本的要求---最合适的图示和配色表达最直观的含义。长文多图预警,这是关于ggplot2使用的极详细教程(190+图),是入门和晋级

关于xshell无法连接虚拟机中linux

遇到xshell无法连接到虚拟机的情况,我在网上看了下,我大概总结为以下几种情况: 1、宿主机或虚拟机中的防火墙阻止了xshell的访问。 2、虚拟机中未安装ssh或者没有启动ssh 3、xshel的22l端口占用 4、网络设置的方式问题 解决方法: 1、关闭宿主机和虚拟机中的防火墙,linux虚拟机中的防火墙关闭为 :service iptab

xshell 终端选中文本后自动执行ctrl+c

1. 退出钉钉后,解决问题, xshell终端可以正常使用了。 2. 修改钉钉设置来解决问题: 设置-> 通用-> AI助理  , 取消指定选项。

安装WMware和Ubuntu并使用xShell连接

0、我的电脑配置 设备名称 hello处理器 Intel(R) Core(TM) i7-10700K CPU @ 3.80GHz 3.79 GHz机带 RAM 16.0 GB (15.9 GB 可用)设备 ID 541EC230-9910-418C-9043-5FBBF8ED320C产品 ID 00330-80000-00000-AA846系统类型 64 位操作系统, 基于 x64

Xshell 连接 Ubuntu 服务器失败问题(Connection failed)

目录 Xshell 连接 Ubuntu 服务器失败问题(Connection failed) 1.查看Ubuntu中是否安装 sshd 2.在Ubuntu中安装sshd 3.需要打开Ubuntu中新安装的sshd 4.在检查Ubuntu中sshd是否安装成功 5.临时关闭Ubuntu中的防火墙 6.Xshell 连接 Ubuntu 服务器成功。 Xshell 连接 Ub