DEV Community

Cover image for Create greetings after the launch Linux Terminal
rendick
rendick

Posted on

Create greetings after the launch Linux Terminal

Hey! Today I will tell you how to create greetings after the launch Linux Terminal.


First, create folder

mkdir welcome-script
cd welcome-script/
Enter fullscreen mode Exit fullscreen mode

After this, you need to create .sh file

touch welcome.sh
Enter fullscreen mode Exit fullscreen mode

You need to open welcome.sh file via Vim

sudo vim ./welcome.sh
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

Edit .bashrc

Open your file manager and paste this command

BashRC

/home/YOURUSER/.bashrc/
Enter fullscreen mode Exit fullscreen mode

And now you need to paste command to .bashrc

Paste

source /home/YOURUSER/welcome-script/welcome.sh
Enter fullscreen mode Exit fullscreen mode

Source code

You can easily download this script from my GitHub repository.

Source code

Top comments (3)

Collapse
 
moopet profile image
Ben Sinclair

Hi Kostaintyn.

A few points about your post:

Your code block has the line

u="$USER"
Enter fullscreen mode Exit fullscreen mode

...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 use sudo here:

sudo vim ./welcome.sh
Enter fullscreen mode Exit fullscreen mode

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.

Collapse
 
rendick profile image
rendick

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

Collapse
 
cappe987 profile image
Casper

You don't need to create a folder and separate script. You can simply put all the code into your .bashrc file directly.