AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 809590
Accepted
kpie
kpie
Asked: 2016-08-09 03:14:58 +0800 CST2016-08-09 03:14:58 +0800 CST 2016-08-09 03:14:58 +0800 CST

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

  • 772

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

我保存了一些调色板,我希望每次打开终端时都通过我保存的配置文件进行默认设置,这样如果我打开 3 它们都是不同的颜色,而无需我手动更改 2 上的配置文件。

有什么想法吗?

谢谢!

command-line
  • 4 4 个回答
  • 13285 Views

4 个回答

  • Voted
  1. Anwar
    2016-08-13T00:36:17+08:002016-08-13T00:36:17+08:00

    一种选择可能是使用xfce4-terminal. 它与默认的 Ubuntu 终端(即gnome-terminal)非常相似,并且它的许多依赖包都使用 gtk 组件,这使其成为一个合适的替代品。

    首先安装它

    sudo apt-get install xfce4-terminal
    

    然后打开它,转到Edit -> Preferences,选择Colors Tab 并检查选项,Vary the background color for each Tab,然后退出。

    设置默认终端xfce4-terminal或更改Ctrl-Alt-T打开它的快捷方式。

    现在,每次打开时,您都会看到不同的调色板。 不同颜色的终端

    有用的链接:

    • 如何更改全局热键/键盘快捷键?
    • 12
  2. Best Answer
    IanC
    2016-08-12T19:31:17+08:002016-08-12T19:31:17+08:00

    功能版

    指示:

    此脚本认为您正在使用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
    

    测试但不广泛。享受!

    • 10
  3. theabhinavdas
    2016-08-12T03:33:49+08:002016-08-12T03:33:49+08:00

    哈哈,很有意思。我也可以尝试这样做。我大多只运行多个终端和一个浏览器。

    所以我环顾四周,发现了这个 - https://github.com/sos4nt/dynamic-colors。一个非常简洁的小项目,可以帮助您实现您想要的一部分。

    现在,在该colorschemes/项目的目录中,您会看到它当前有 4 种配色方案。您可以根据需要/想要添加任意数量。

    因此,为了让每个终端选择不同的配色方案,我会在我的.bash_profileor.bashrc或任何地方添加一个函数,这样该函数会做两件事:

    1. 计算出当前正在运行的终端数量
    2. dynamic-colors switch colorscheme-name根据 (1)发出命令。

    希望这可以帮助!

    PS我会为你写一个脚本,但我讨厌用勺子喂食而且我很懒。:)

    • 5
  4. Matt O.
    2016-08-12T16:29:58+08:002016-08-12T16:29:58+08:00

    Konsole 实际上本机支持此功能。Konsole 非常强大且高度可定制。

    如果您没有 Konsole,那么只需sudo apt install konsole

    1. 前往设置
    2. 控制台设置
    3. 选择外观选项卡
    4. 选择你的配色方案
    5. 选择右侧的“编辑”
    6. 有一个框可以设置“更改每个选项卡的背景颜色”

    最重要的是,如果您同时在三台服务器上工作,则可以包括此处显示的一些漂亮别名

    • 2

相关问题

  • 如何从命令行仅安装安全更新?关于如何管理更新的一些提示

  • 如何从命令行刻录双层 dvd iso

  • 如何从命令行判断机器是否需要重新启动?

  • 文件权限如何工作?文件权限用户和组

  • 如何在 Vim 中启用全彩支持?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve