简体   繁体   English

在 Linux 中添加脚本以在启动终端 bash shell 时显示日期

[英]Adding script in Linux to display date at start up terminal bash shell

I have a hw problem where I need to make the date appear at the start up screen of the terminal in bash shell.我有一个硬件问题,我需要在 bash shell 的终端启动屏幕上显示日期。 I was able to save date script using nano, but am now stumped on how to get it to show up when launching terminal.我能够使用 nano 保存日期脚本,但现在我对如何在启动终端时显示它感到困惑。 Any help is appreciated.任何帮助表示赞赏。

You can create a desktop shortcut launcher that will start your script in a terminal.您可以创建一个桌面快捷方式启动器,它将在终端中启动您的脚本。

     $ gedit ~/Desktop/dateterminal.desktop

Copy the following (change the exec line to your script)复制以下内容(将 exec 行更改为您的脚本)

    [Desktop Entry]
    Version=1.0
    Type=Application
    Terminal=true
    Exec=/path/to/your/date/script
    Name=whatever you want
    Icon= 

After creating right click on the launcher > Properties > Permissions > & check the Execute: box创建后右键单击启动器 > 属性 > 权限 > 并选中执行:框

Here you go:干得好:

I am not really sure if you want a motd in CLI or if you want a message for everytime you opening a new tab or logging in or if it's before you logging in(MOTD) but since you have a script I guess it's in a terminal window everytime you opening a new tab: 我不确定您是否想要 CLI 中的 motd,或者您是否想要每次打开新选项卡或登录时的消息,或者是否在您登录之前(MOTD)但由于您有一个脚本,我猜它在终端中每次打开新标签时的窗口:
 mkdir -p ~/.scripts # Put your script in ~/.scripts echo ". ~/scripts/yourscript.sh" >> ~/.bashrc source ~/.bashrc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM