kpi*_*pie 16 colors command-line automation
我经常发现自己打开了三个终端,我真的很喜欢每个终端都有不同调色板的外观和感觉。
我保存了一些调色板,我希望每次打开终端时默认设置都在我保存的配置文件中进行,这样如果我打开 3 它们都是不同的颜色,而我不必手动更改 2 上的配置文件。
有什么想法吗?
谢谢!
Anw*_*war 11
一种选择是使用xfce4-terminal. 它与默认的 Ubuntu 终端(即gnome-terminal)非常相似,并且它的许多依赖包都使用 gtk 组件,这使其成为合适的替代方案。
首先安装它
sudo apt-get install xfce4-terminal
Run Code Online (Sandbox Code Playgroud)
然后打开它,转到Edit -> Preferences,选择Colors Tab 并检查显示的选项,Vary the background color for each Tab,然后退出。
制作默认终端xfce4-terminal或更改Ctrl-Alt-T打开它的快捷方式。
有用的链接:
指示:
该脚本认为您正在使用gnome-terminal,这是默认的 Ubuntu 终端。
在运行脚本之前,打开gnome-terminal并根据需要创建一些具有不同设置的配置文件(编辑>首选项>配置文件)(背景颜色、文本颜色等)。您可以将它们命名为 Profile1、Profile2、Profile3 等。创建足够的配置文件以涵盖将打开的终端数量,但如果打开的终端数量更多,则将使用默认配置文件。
该脚本创建一个文件~/.Bash_Color_Changer,它取决于它,因为它会告诉脚本终端是定期打开还是在调用.bashrc之后打开。
将脚本添加到~/.bashrc文件的末尾。
脚本:
添加到.bashrc:
#Change color according to the number of Bash shells opened
#Creates the .Bash_Color_Changer file if it's not present
if ! [ -f ~/.Bash_Color_Changer ]; then
echo ORIGINAL > ~/.Bash_Color_Changer
fi
#Array holding the name of the profiles: Substitute it for the names you're using
Color_counter=(Profile1 Profile2 Profile3)
#Finds out the number of opened bashs counting the lines containing "bash"
#in the pstree function. (-c deactivates compact display to avoid it showing
#lines with "2*[bash]" instead of one for each bash)
Number_of_bashs=$(($(pstree -c | grep "bash" | wc -l)-1))
#Checks if the terminal being opened was opened by the user or by
#the script, and act according to it
if [ $(cat ~/.Bash_Color_Changer) = ORIGINAL ]; then
if ((Number_of_bashs < ${#Color_counter[*]})); then
echo COPY > ~/.Bash_Color_Changer
gnome-terminal --tab-with-profile-internal-id=${Color_counter[${Number_of_bashs}]}
exit
fi
else
echo ORIGINAL > ~/.Bash_Color_Changer
fi
Run Code Online (Sandbox Code Playgroud)
测试但不广泛。享受!
哈哈,很有意思。我也可以尝试这样做。我主要只运行多个终端和浏览器。
所以我环顾四周,发现了这个 - https://github.com/sos4nt/dynamic-colors。一个非常整洁的小项目,可以帮助您实现您想要的一部分。
现在,在该colorschemes/项目的目录中,您将看到它目前有 4 种配色方案。您可以根据需要/想要添加任意数量。
因此,为了让每一个终端来选择不同的颜色方案,我想补充一个函数到我.bash_profile或.bashrc或其他地方,使得功能做两件事情:
dynamic-colors switch colorscheme-name基于(1)的命令。希望这可以帮助!
PS 我会为你写一个脚本,但我讨厌用勺子喂食,而且我很懒惰。:)
| 归档时间: |
|
| 查看次数: |
11699 次 |
| 最近记录: |