Hey! Today I will tell you how to create greetings after the launch Linux Terminal.
First, create folder
mkdir welcome-script
cd welcome-script/
After this, you need to create .sh file
touch welcome.sh
You need to open welcome.sh file via Vim
sudo vim ./welcome.sh
Basic commands
echo - command that output text, etc.
Variable (programming) - named
Commands in a variable - output anything, function
sleep - time to finish something after the time
u - variable for Linux function(like Username, OS version, etc)
$ - for output Linux command. Example: os=$(whoami) (variable=function for command(command)
Code
#!/bin/bash
name="Name"
u="$USER"
echo " "
echo " "
echo "░█░█░█░█▀▀▀░█░░░░█▀▀▀░█▀▀█░█▀█▀█░█▀▀▀░"
echo "░█░█░█░█▀▀▀░█░░░░█░░░░█░░█░█░█░█░█▀▀▀░"
echo "░▀▀▀▀▀░▀▀▀▀░▀▀▀▀░▀▀▀▀░▀▀▀▀░▀░▀░▀░▀▀▀▀░"
sleep 1
echo " "
now=$(date)
echo "Current time: $now"
echo " "
echo "Hello $USER!"
sleep 1
echo " "
os=$(uname -r)
echo "Your OS is $os"
echo " "
sleep 1
setup=$(neofetch)
echo "Your PC stats: $setup"
echo " "
sleep 1
Edit .bashrc
Open your file manager and paste this command
/home/YOURUSER/.bashrc/
And now you need to paste command to .bashrc
source /home/YOURUSER/welcome-script/welcome.sh
Source code
You can easily download this script from my GitHub repository.
Top comments (3)
Hi Kostaintyn.
A few points about your post:
Your code block has the line
...but then you don't use
$u
anywhere. Did you miss something out when you copied from your script file?You mention using Vim to edit a file but then your next example is editing
.bashrc
with KWrite? And why do you usesudo
here:There's no reason to edit a local script that's going to be executed by your user, as root.
Lastly, the link to your GitHub repository is broken somehow - it's rendering as an image instead of as a text link.
Hi, I'm sorry about that. I already fixed the link to my repository at GitHub.
You can edit .bashrc with any editor you like, I personally used KWrite
You don't need to create a folder and separate script. You can simply put all the code into your .bashrc file directly.