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
    • 最新
    • 标签
主页 / user-993645

Student of Science's questions

Martin Hope
Student of Science
Asked: 2020-06-02 05:49:26 +0800 CST

自定义 bash shell

  • 2

我想以一种非常具体的方式自定义我的 bash shell,具体到我不知道是否可行。目前,我的外壳是这样的:

myname@ubuntu /home/myname:
>>

其中 myname 是我的用户名。我在以下行中自定义了外壳~/.bashrc:

PS1='${debian_chroot:+($debian_chroot)}\u@\h `pwd`:\n>> '

当我按 Enter 键时,会发生以下情况:

myname@ubuntu /home/myname:
>>
myname@ubuntu /home/myname:
>>

取而代之的是,我希望发生以下情况:

myname@ubuntu /home/myname:
>>
>>

此外,如果我输入一个命令,会发生什么应该是这样的:

myname@ubuntu /home/myname:
>> echo hello
hello
myname@ubuntu /home/myname:
>>

以下情况不应发生

myname@ubuntu /home/myname:
>>echo hello
hello
>>

这可能吗?如果是这样,该怎么做?

更新

多亏了 ChrisAga 的回应,我才得以实现我的目标。

这是脚本

# don't put duplicate lines or lines starting with space in the history.
HISTCONTROL=ignoreboth

customprompt() {
    # the current number of lines in bash history:
    bash_history_size=$(fc -l -1)
    bash_history_size=${bash_history_size%%[^0-9]*}

    # set an initial value to the number of lines
    # in bash history stored from the last time
    # this function was executed. This avoids bugs
    # when running the first command in the current
    # shell session
    if [ -n "$bash_history_lastsize" ]; then
        bash_history_lastsize=0
    fi

    # if the current number of lines in bash history
    # is different from the last number of lines, then
    # we print the user name and the current directory.
    # otherwise, we just print >>
    if [ "${bash_history_size}" != "${bash_history_lastsize}" ]; then
        PS1='\[\033[01;32m\]\u@\h \[\033[00m\]`pwd`:\n>> '
    else
        PS1=">> "
    fi

    # update the last value to the current value
    bash_history_lastsize=${bash_history_size}
}

PROMPT_COMMAND=customprompt
command-line bash
  • 2 个回答
  • 351 Views
Martin Hope
Student of Science
Asked: 2020-05-29 13:16:23 +0800 CST

让 Ubuntu 的 Night Light 看起来像 Manjaro KDE 的 Night Color

  • 2

如何让 Ubuntu 的夜灯看起来像 Manjaro KDE 的夜色?我想要这个,因为 Manjaro 的 Night Color 具有更多功能,可以让我按照自己的方式自定义设置。

这是 Ubuntu 夜灯的截图:

Ubuntu的夜灯

以下是 Manjaro KDE 的 Night Color 的一些截图:

Manjaro KDE 的夜色 - 2 Manjaro KDE 的夜色 - 3

如您所见,Manjaro KDE 中还有很多功能(可以为色温设置特定值,可以使其始终亮起,可以设置特定位置)

注意:我不想安装redshift或flux. 请不要这样建议。我对这些应用程序的体验很糟糕,例如随机出现的错误和崩溃。

更新:

我知道我可以在 GNOME 中更改夜灯的色温。确实,我已经在这样做了。我在 bash shell 中输入了一个命令来设置所需的温度颜色。但是,这不是我的问题的答案。我不是在寻找仅更改色温的方法。我想要的是一个漂亮的 GUI 界面,我可以在其中做这些事情等等。我也知道该dconf-editor应用程序,它还允许更改夜灯的颜色。但是,如前所述,这不是我唯一要寻找的东西。我正在寻找更用户友好的东西。

kde color-management colors gnome-shell night-light
  • 2 个回答
  • 1134 Views

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