Add Separator Line Between Commands on Linux Terminal

3:51 PM

If you are a person who often perform daily tasks via command line interface, you might have ever performed multiple commands at once (usually by adding "&&" between them). But, you might be confused when analyzing the output of every command and when the command is finished. So today, I'd like to show you how to add a handy separator line between commands on Linux Terminal.


As you can see the picture above, at the end of every command there will be a separator line followed by the time completion of related command. Are you interested in it? OK! Please open your text editor and paste the following code:
  • # Fill with minuses
  • # (this is recalculated every time the prompt is shown in function prompt_command):
  • fill="--- "

  • reset_style='\[\033[00m\]'
  • status_style=$reset_style'\[\033[0;90m\]' # gray color; use 0;37m for lighter color
  • prompt_style=$reset_style
  • command_style=$reset_style'\[\033[1;29m\]' # bold black
  • # Prompt variable:

  • PS1="$status_style"'$fill \t\n'"$prompt_style"'${debian_chroot:+($debian_chroot)}\u@\h:\w\$'"$command_style "

  • # Reset color for command output
  • # (this one is invoked every time before a command is executed):
  • trap 'echo -ne "\e[0m"' DEBUG


  • function prompt_command {

  • # create a $fill of all screen width minus the time string and a space:
  • let fillsize=${COLUMNS}-9
  • fill=""
  • while [ "$fillsize" -gt "0" ]
  • do
  • fill="-${fill}" # fill with underscores to work on
  • let fillsize=${fillsize}-1
  • done

  • # If this is an xterm set the title to user@host:dir
  • case "$TERM" in
  • xterm*|rxvt*)
  • bname=`basename "${PWD/$HOME/~}"`
  • echo -ne "\033]0;${bname}: ${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"
  • ;;
  • *)
  • ;;
  • esac

  • }
  • PROMPT_COMMAND=prompt_command
Save the above code as ".bash_ps1" (don't forget the dot character) and place it in your Home folder.
Lazy copying the code? Download the ".bash_ps1" file here.

Now, edit your ".bashrc" file which is located in your Home folder and append the below code:
  • if [ -f "$HOME/.bash_ps1" ]; then
  • . "$HOME/.bash_ps1"
  • fi
Save the change and run the following command to "apply" your work:
  • source ~/.bashrc

Regards :)

0 comments

» read more....

TermSaver: Terminal Based Screensaver

2:59 AM

TermSaver is a  cool screensaver that can run from the command-line interface or terminal in Ubuntu/Linux. TermSaver isn’t supposed replace other screensavers that come with your desktop such as GnomeShell, Unity, KDE, or other Desktop Environment.

And it also might not be able to carry out the actual purpose of a screesaver since it lacks a lot of pixel movements (screen animations), which otherwise helps to prevent “screen burns” on display devices.

But if you are using command-line as your primary interface or, if you’re a desktop user who usually uses the Terminal emulator and looking for a screensaver that’s quite fun to use, then you might wanna try “TermSaver”.

Installing TermSaver in Ubuntu

Install pip a tool for installing and managing Python packages
  • $  sudo apt-get install python-pip python-dev build-essential
Now you are ready to install TermSaver on your machine, issue the following command at the terminal.
  • $ sudo pip install termsaver
Using TermSaver

Issue the following command in the terminal,
  • $ termsaver --help
This will list out the arguments to be used with termsaver command to display the text based screensavers.
Usage: termsaver [screen] [options]

Screens:

 clock                     displays a digital clock on screen
 randtxt                displays word in random places on screen
 dot                        displays a random running dot
 asciiartfarts       displays ascii images from asciiartfarts.com (NSFW)
 rfc                         randomly displays RFC contents
 quotes4all          displays recent quotes from quotes4all.net
 programmer     displays source code in typing animation
 urlfetcher          displays url contents with typing animation
 jokes4all             displays recent jokes from jokes4all.net (NSFW)
 rssfeed                displays rss feed information

For example if I use the asciiartfarts as the screen for termsaver
  • $ termsaver asciiartfarts
this will show the random ascii art from asciiartfarts.com unless I terminate it using Ctrl + C


 Enjoy!

0 comments

» read more....

Fu: CommandLineFu.com from the Command Line

11:09 AM

Before starting, please let me tell you what CommandLineFu.com is:

Commandlinefu.com is an online repository for recording commandline gems, that you return to again and again
By now, CommandLineFu already has 8,897 commands to get many things done via command line interface (CLI). What is Fu? As simply as its name, Fu is a command line interface which allows us to search, copy, and display information on CommandLineFu.com based on given keyword. For example, you want to what commands related to PDF file, Fu will give you this information:


Installation on Ubuntu
Type the following command to install Fu on Ubuntu:
  • git clone git://github.com/samirahmed/fu.git
  • cd fu/
  • sudo make install
Brief usage instruction
For example, you want to search commands related to PDF file, the command you should type is:
  • fu pdf
By default, Fu only displays three commands. If you want to display ALL commands available, type the following command:
  • fu -a pdf
In case, there are too many results on the screen, you can limit the number of the search results:
  • fu -n 5 pdf
The above command will only display five commands on the screen.
Fu is capable to display URL related to the commands and vote given to it.
  • fu -v pdf


Well, if you find any interested command, you can copy it to the clipboard, by typing the following command:
  • fu -c number-of-command
Change number-of-command with the number related to the command displayed on screen.

For further information, below is video which shows us how to use Fu, enjoy!




Regards :)

0 comments

» read more....

Playterm: Embed Your Terminal Recordings Online

10:32 PM

Playterm is a web service which can replay your terminal sessions online, by providing embedcodes which you can put onto your blog, article or website. This is very useful especially for you who often makes tutorials or presentations about Command Line Interface (CLI) in your online articles.


Why you should use Playterm?
There are several reasons to use PLAYTERM, and replay terminal recordings online:
  • its extremely educative
  • best promotion-tool for CLI application(s) for ALL audiences!
  • you can explain, and perform commands at the same time
  • its more timesaving and readable than recording a playterm.g, or wink movie
  • its timesaving: a tutorial AND showcase at the same time.
  • uses less bandwidth then flash(video) solutions
  • lightweight javascript embedcode to drop in your blog/article/website
  • promote and present your commandline app the web 2.0 way!
Unfortunately, Playterm doesn't allow us to set our own video size. It has only two size of video: 80x24  pixels and 120x35 pixels.

If you are interested in recording your Terminal activity and share it with your friends, you might enjoy using Playterm:

Playterm: Embed Your Terminal Recordings Online

How to record my Terminal activity? Please click here to get the instruction to do so.

0 comments

» read more....

Axel: Command Line Download accelerator

2:16 AM

You must have read or heard about wget command line download utility. It provides  immense capabilities, but when it comes to accelerating the download speed, wget doesn't provide any option. But Axel is one such tool which do the job of a download accelerator very well.
Axel does the same thing any other accelerator does: it opens more than one HTTP/FTP connection per download and each connection transfers its own, separate, part of the file.

Downloading Axel

For Ubuntu Axel is available in the default apt repositories, open the terminal and issue the following command.
  • $ sudo apt-get install axel

Using Axel


Download from multiple locations
  • $ axel <url1> <url2> <url3>
This will use all these mirrors to download the file.

Limit the download speed
  • $ axel -s 3000000 <url>
Mention the speed in bytes per second.

Limit the number of concurrent connections or threads
  • $ axel -n 3 <url>
Change the name of the output file
  • $ axel -o output_file.ext <url>
Mentioning a directory will save the file in that directory.

View the download information of each connection or thread
  • $ axel -a n 3 <url>

Thanks for reading :-)

0 comments

» read more....

Twidge: Twitter Client for Linux Terminal

9:30 PM


Twidge is a terminal client for microblogging sites such as Twitter and identi.ca.

Twidge is a full command-line client. It is designed to be useful when you’re sitting at a shell prompt. It produces output in well-formed and easily-parsed ways, and has various features for working with piped data.

There are other command line tools for twitter which are also available, but most of them are not updated for the changes in twitter security settings.
Here is how you can install and configure Twidge,

Twidge is available in the oneiric apt repositories, so if you are using Ubuntu 11.10 you just need to install Twidge using the install command.
  • $ sudo apt-get install twidge
But if you are using any other version of Ubuntu, you need to manually add the repositories for Twidge.
  • $ sudo gedit /etc/apt/sources.list
Append the following line at the end of the text,
deb http://ftp.de.debian.org/debian squeeze main
Save this repository to your sources.list to be able to download Twidge. In order to install from the command line, run:
  • $ sudo apt-get update 
  • $ sudo apt-get install twidge
Twidge Setup:

 Issue the following command in the terminal
  • $ twidge setup
Twidge Setup will generate a URL for the authentication (see the below image), copy the URL and paste it into your browser, it will ask you to login with your login credentials, just login and it will generate an authentication code.

Enter the authentication code in the terminal, and you are done and ready tweet the geek way :)


Some useful Twidge commands:

For the detailed description for the twidge commands look inside Twidge man pages.
  • $ man twidge
Or, you use lscommand to see the full list of commands at glance,
  • $ twidge lscommands
Here are some quick commands for day to day usage,

Status update:
  • $ twidge update
And then typing your 140 character update,

Check your @replies:
  • $ twidge lsreplies
Check most recent updates:
  •  $ twidge lsrecent


Lets tweet the geek style :)

0 comments

» read more....

Weather Information in Linux Terminal

2:37 AM

Linux Terminal makes life easy for day to day administration on a Linux Desktop. And if you are a Power user and spend most of the time on the command prompt, you might want to have some dynamic information such as Weather condition available each time you open the Terminal.



Here is a way to get Weather Information in the Linux Terminal both in graphic (gnome, KDE, Unity) and text login (Ctrl + Alt + F1 to F7) modes.

First install the weather-util package from apt repositories.
  • $ sudo apt-get install weather-util
You’ll need your local weather code, which you can get from this website.

For Graphic Login:

Open the .bashrc file
  •  $ sudo vi ~/.bashrc
Press Insert, And append the following lines at the end of the file.

# Weather Information
weather -i CODE 
Where CODE is the code of your location, like VIDP is the code of New Delhi in my case.

Press Esc, and :wq to save and exit the vi editor.

Close the Terminal and reopen, it will display the weather information before the bash prompt.

For Text Login:

You first need to create a script in the appropriate location using vi editor.
  • $  sudo vi /etc/update-motd.d/98-weather
Press Insert and enter the following code, replacing CODE with your local weather code
#!/bin/sh
echo
weather -i CODE
echo
Press Esc, and :wq to save and exit.

Make it executable using chmod
  • sudo chmod +x /etc/update-motd.d/98-weather

Press Ctrl + Alt + F1 and login to see the script working.

Voila :)






0 comments

» read more....