top of page

Ba$h ~/Scripting

Writer's picture: Robert ForsythRobert Forsyth

At the start of the new year, I decided to dive deeper into learning the components of a Linux system by taking the free online FS101 course from the Linux Foundation. I’m doing this because I want to better integrate my knowledge of 3D modelling, CNC manufacturing, Computing, and open-source software professionally. In the process, I discovered my love for Bash scripting.


Writing a bash script in Kate to manage the installation of cmatrix with interactive user prompts for colour preferences.
Writing a bash script in Kate to manage the installation of cmatrix with interactive user prompts for colour preferences.

The linux command line is really powerful, and having the ability to pre-define some commands I use regularly is fantastic. Not only does it save time, but I don’t have to remember the 'flags'. Anyone who has used Linux systems before knows that it can be a pain. For example; “-f”, “-F” or “—Flag”, are might all be valid options.


 

On a side note to find out what the flags mean you have a few options. First is the “man” command. This displays the manual page for the command. For example; “man ls”


“info” works in a similar way but it’s more in-depth and uses the shortcut keys “n” and ”p” to navigate forward and backwards. “u” will go up a node.. ..yes the pages are called nodes (I am still confused that someone decided to call information pages nodes). You can learn more about the info pages by typing “info info” into your bash terminal.


Another option is the “--help” or “-h” flag. These flags display a short summery of the help pages. I find this option the most helpful.


Aside from that, you can also use documentation or the internet to search for answers.


 

Back on track with Bash Scripting; I managed to write an application launcher that when “launshell” is typed it enables me to type my own shortcuts for longer commands. This makes use of unicode emoji’s, colours and the fun command lolcat.


Custom Bash Script: A Convenient Home-Made Application Launcher for Daily Tools and Commands.
Custom Bash Script: A Convenient Home-Made Application Launcher for Daily Tools and Commands.


Lolcat is a command that applies a rainbow colour effect to text on the screen, by piping the command through it, like this;


ls -l | lolcat

You will probably have to install lolcat yourself if you want to try it out. You can do that by entering the command below. Followed by your administration password;


sudo apt install lolcat


My home directory has never looked so funky!




The command I find most favourable is the curl command, combined with the website “wttr.in”. If you add your city name like a directory at the end, curl will download and print to the screen a weather report, for that city; “curl https://wttr.in/exeter?%M”. The “?%M” at the end tells wttr to send the information in a metric format.



More can be found out about "wttr.in" on its GitHub pages;



Below I have included a code snippet for you to try "wttr" yourself in your own bash terminal. simply type the name of a large town or city near you in-place of "budapest";


 

Speaking of GitHub I created my own account to store my code and download it to any system I build. hopefully this also adds to my professionalism as a opensource maker/designer. You can view it here;



I have been having issues with GitHub lately, so I created an account on the open source friendly "Codeberg". My files can be found by following the link below;



I’m really excited to keep learning more about Bash scripting and exploring how Linux can help me streamline my workflow. If you're also diving into Linux, I’d love to hear about your experiences or any tips you have. Especially if you have any favourite Bash scripts or commands that help streamline your workflow?

6 views0 comments

Recent Posts

See All

Why Did Facebook Ban Mentioning Linux?

Recently, Facebook (now Meta) made headlines for banning mentions of Linux[1], including DistroWatch—“a website dedicated to discussing,...

Comments


  • Facebook
  • Instagram

Join our mailing list

Thanks for submitting!

© 2024 - not that anyone reads this!

bottom of page