每次打开终端时自动获得不同的终端颜色

p

我经常会发现自己打开了三个终端,我真的很喜欢每个终端都有不同调色板的外观。

我保存了一些调色板,我希望每次打开终端时都能通过默认的设置来浏览保存的配置文件,因此,如果我打开3种,则每种颜色都是不同的,而无需手动更改2种配置文件。

有什么想法吗?

谢谢!

IanC

功能版本

指示:

脚本认为您使用的是gnome-terminal,这是默认的Ubuntu终端。

在运行脚本之前,请打开gnome终端,并根据需要创建一些具有不同设置的配置文件(“编辑”>“首选项”>“配置文件”)(背景颜色,文本颜色,..)。您可以将它们命名为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

经过测试,但未进行广泛的测试。享受!

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

每次打开新终端时,如何使laravel自动运行?

每次打开新的终端窗口时,如何自动记录终端会话?

打开时自动捕捉终端(或Nautilus)

打开终端时自动执行命令

每次打开终端时,已经执行了几个命令

每次打开终端时执行一条命令

dyld:库未加载:每次打开终端时显示

从颜色池中获得不同的颜色

每次从BeautifulSoup获得不同的结果

打开gnome终端时如何自动启动tmux

打开终端时自动运行命令(Linux Mint 16)

打开PHPStorm项目时可以自动运行终端命令吗?

打开新终端时如何自动启动byobu?

打开新的终端窗口时,如何自动启动GNU Screen?

如何在ubuntu启动时自动打开终端?

防止集成终端自动打开

每次在tkinter中按下按钮时,如何获得不同的标签值?

打开终端时出现错误

启动时打开终端

在终端中获得不适当的输出

如何获得MATE终端的日晒颜色主题?

如何从终端打开终端

每次从文件资源管理器打开终端时,如何获取 PowerShell 当前位置

每次我在服务器上打开新终端时如何执行命令

为什么每次打开终端以使别名正常工作时都必须来源.bashrc?

每次打开终端时,都会不断收到消息“ 404 ::命令未找到”

每次打开终端(Ubuntu 16.04)时都出现“找不到命令'pew'”

每次打开终端时在Linux中使用crontab显示消息吗?

每次打开 Ubuntu 终端时都没有这样的文件或目录