How to Run Neofetch or Fastfetch Only Once on Terminal Startup?

0
1981
Asked By CuriousCoder42 On

I'm trying to set up my terminal so that Neofetch or Fastfetch runs automatically, but only the first time I open a terminal. I've added Neofetch to my .bashrc file, but it shows up every single time I open a new terminal window. Is there a way to make it run just once? For context, I'm using Ubuntu Gnome.

3 Answers

Answered By TechWhiz88 On

To achieve that, you can create a temporary file that indicates whether the command has already been run. Here’s a quick script you can add to your .bashrc:

```bash
if [[ ! -f /dev/shm/fetchblock ]]
then
touch /dev/shm/fetchblock
fastfetch # or use neofetch here
fi
```

This script checks for a file named `fetchblock`. If the file isn't there, it creates it and runs your command. Just remember, `/dev/shm` is a temporary storage, so this file will disappear with a reboot. If you prefer, you could use `/tmp` or another temp directory!

LinuxLover101 -

Got it! I just learned that Neofetch isn't being updated anymore. I might need to switch to Fastfetch if it starts acting up.

Answered By CodingNinja77 On
Answered By ShellGuru23 On

How exactly did you add Neofetch to your .bashrc?

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.