How to have a nice bash shell prompt that will print the current git branch on the prompt.

This interesting bash function will get the git branch of the current working directory and then print it in the shell prompt. This could be very useful for a programmer. git_branch() { git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/(\1)/’ }   PS1=’┌──[\u@\h]─[\w]\n└──╼ $(git_branch) ╼ \$ ‘git_branch() { git branch 2> /dev/null … Read more

How to generate a very nice colored desktop background with the command line.

The Linux command line is very useful and it can even generate you a nice wallpaper image using just the shell and ImageMagick. The example below will generate a 3440×1440 pixels wallpaper image using just the random data from /dev/urandom. ┌─[jason@jason-desktop]─[~/Documents] └──╼ $mx=320;my=256;head -c "$((3*mx*my))" /dev/urandom | convert -depth 8 -size "${mx}x${my}" -resize 3440×1440\! -channel … Read more

Youtube-dl automatic update not working.

The updates for youtube-dl do not work anymore on Ubuntu, but it can be updated manually. Download the script here: https://youtube-dl.org/downloads/latest/youtube-dl. Then copy the script over the top of the existing one in /usr/bin and then make sure it has the executable flags 755. This is very easy. Download it very easily. ┌─[jason@jason-desktop]─[~/Downloads] └──╼ $wget … Read more

Some very useful Linux tips and tricks.

To read a file from the Internet using wget and print it in the terminal, use this command. ┌─[jason@jason-desktop]─[~/Documents] └──╼ $wget -qO – https://i.mjh.nz/au/Brisbane/raw-tv.m3u8┌─[jason@jason-desktop]─[~/Documents] └──╼ $wget -qO – https://i.mjh.nz/au/Brisbane/raw-tv.m3u8 View an image from the Internet with wget and the ImageMagik display utility. ┌─[jason@jason-desktop]─[~/Documents] └──╼ $wget -qO – https://i.4cdn.org/g/1603231784644.png | display┌─[jason@jason-desktop]─[~/Documents] └──╼ $wget -qO – https://i.4cdn.org/g/1603231784644.png … Read more

How to get ID3 information from a multimedia file with ffmpeg.

The ffmpeg utility is very useful for transcoding video and making video files, but it can also retrieve information from a video or audio file very easily. You can get the ID3 info from an mp3 very easily. Below is an example. I am getting album and artist information from an mp3 audio file. jason@jason-desktop:~/Music/Ludwig … Read more

How to configure bash to have nice auto-completion.

Put this code in your ~/.inputrc file to enable nice auto-completion in the bash shell prompt. ~\.inputrc1 2 3 4 5 6 7 8 9 10 $include /etc/inputrc set completion-ignore-case on set completion-query-items -1 set show-all-if-unmodified on set show-all-if-ambiguous off set colored-completion-prefix on set colored-stats on set visible-stats on "\C-j": menu-complete "\C-k": menu-complete-backward$include /etc/inputrc set … Read more

How to get the desktop resolution of your monitor on Linux using the command line.

Getting information about your desktop resolution with the Linux command line is very easy to do. This one-liner will print the current desktop resolution. This could be used in a script that will then do something with the output. jason@jason-desktop:~/Videos$ xrandr | awk ‘{if(NR==5) print $0}’ | awk ‘{print $1}’ 3440x1440jason@jason-desktop:~/Videos$ xrandr | awk ‘{if(NR==5) … Read more

How to print a list of all ABC News articles with the Linux command line.

This one-liner will print a listing of all ABC News articles from the XML RSS feed. This is a very good way to extract text from an RSS feed or other XML files. curl -s http://www.abc.net.au/news/feed/2942460/rss.xml | grep ‘media:description’ | awk -F "[<>]" ‘{print $3}’; echo "$desc"curl -s http://www.abc.net.au/news/feed/2942460/rss.xml | grep ‘media:description’ | awk -F … Read more

Very useful bash shell tips for Ubuntu.

There are some tips for Ubuntu that are not as well known as they should be. One tip is searching the bash history. Press Control-R and a prompt will appear. (reverse-i-search)`sudo’: sudo apt-get install libxml2-utils(reverse-i-search)`sudo’: sudo apt-get install libxml2-utils Type a search like “sudo” for example, and the first search result will cope up, this … Read more

Very nice bash shell prompt and other useful Linux information.

Very nice bash shell prompt This is a very useful Linux shell prompt with color. export PS1="\[\033[38;5;165m\]\d\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;51m\]\W\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;84m\]\H\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;229m\]\u\[$(tput sgr0)\]:\l>\[$(tput sgr0)\]\[\033[38;5;231m\]\\$\[$(tput sgr0)\] "export PS1="\[\033[38;5;165m\]\d\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;51m\]\W\[$(tput sgr0)\] \[$(tput sgr0)\]\[\033[38;5;84m\]\H\[$(tput sgr0)\]@\[$(tput sgr0)\]\[\033[38;5;229m\]\u\[$(tput sgr0)\]:\l>\[$(tput sgr0)\]\[\033[38;5;231m\]\\$\[$(tput sgr0)\] " This prompt will look like this. Mon Mar 30 ~ Yog-Sothoth@jason:0>$ This is … Read more

How to use the command line to change GTK settings easily.

The settings used by the file chooser in MATE or Gnome can be changed easily with the command line. The gsettings utility makes this easy. This example will alter the Firefox file chooser, it will have directories listed first, in descending order, sorted by date modified. gsettings set org.gtk.Settings.FileChooser sort-column ‘modified’ gsettings set org.gtk.Settings.FileChooser sort-order … Read more

How to easily download whole albums and tracks from Bandcamp on Linux.

The Bandcamp website hosts a lot of music, and it is very easy to download music from the website easily on Linux. Firstly, install the Python pip3 addon. 4.4 Sat Jan 18 jason@Yog-Sothoth 0: $ sudo apt install python3-pip4.4 Sat Jan 18 jason@Yog-Sothoth 0: $ sudo apt install python3-pip Then, install the Python Bandcamp script. … Read more