Wednesday, June 13, 2012

How to Color Man Pages & How It Works



In this tutorial I’ll show how to get some nicely colored man pages by adding several lines inside the .bashrc file, explaining what the code means and how it works.

Except for the eye-candy, colors may help when it comes to clarity, although some prefer the default monochrome approach. At the start of this article there is the actual code which can be copied and pasted inside the ~/.bashrc file, and which can be modified depending on each person’s preferences. If you don’t care about what it does you can just insert it in ~/.bashrc, restart your terminal and start reading some man pages to see how it looks (e.g. man man). After this part I tried to explain how this code works and how to modify it in order to get new ‘themes’.

The code
For this tutorial we’ll be editing the ~/.bashrc file, which is a hidden file located in your home directory which gets read each time a new Bash instance starts up. Bash reads all the commands found in this file and executes them (hence the rc part, which stands for run commands).
We will edit this file and add some lines which specify certain colors for the $LESS_TERMCAP variables.

export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode - red
export LESS_TERMCAP_md=$(printf '\e[01;35m') # enter double-bright mode - bold, magenta
export LESS_TERMCAP_me=$(printf '\e[0m') # turn off all appearance modes (mb, md, so, us)
export LESS_TERMCAP_se=$(printf '\e[0m') # leave standout mode
export LESS_TERMCAP_so=$(printf '\e[01;33m') # enter standout mode - yellow
export LESS_TERMCAP_ue=$(printf '\e[0m') # leave underline mode
export LESS_TERMCAP_us=$(printf '\e[04;36m') # enter underline mode - cyan
Don’t forget to reset your terminal after entering this code in order for the changes to take effect, e.g. type reset or exit and start up another shell.
This will mostly use magenta and cyan as the colors. Next, I’ll explain what these lines mean and how you can modify the colors.

Explaining it

As you can see, there are several variables which are assigned different values. As shown in the comments after the # sign, every one is used when needed. When text is in bold (double-bright mode), the formatting option is set to bold and the color magenta.
Let’s take, for example, the following line:

export LESS_TERMCAP_md=$(printf '\e[01;35m') # enter double-bright mode - bold, magenta

This line could be broken into this:
  • the environment variable LESS_TERMCAP_md will be assigned the value to the right of the equal sign
  • the right side says execute the command between the $( and ) characters, just like the older ` ` did
  • printf is a command similar with C’s printf and means “print with format”. The characters between the double quotes specify a color and a font style (e.g. in this case, bold and magenta).
The part that is inside the double quotes are format specifiers like bold, regular, or color to be used. More on these can be found on Wikipedia, here.

Color codes

The color codes are as follows:
  • 30 – black
  • 31 – red
  • 32 – green
  • 33 – orange
  • 34 – blue
  • 35 – magenta
  • 36 – cyan
  • 37 – white
Some other escape codes which you could use include:
  • 0 – reset/normal
  • 1 – bold
  • 3 – italic/reversed
  • 4 – underlined
  • 5 – blink
You can check this by typing in a terminal something like:

printf '\e[31m'
printf '\e[32m'
printf '\e[37m'
So, if we have something like printf ‘\e[01;33m’ it means enter bold and color yellow, according to the listing above.

What about ‘export’?

export is a Bash built-in used to assign values to variables in such a manner that any subsequent application that runs in that shell will be aware of the variable’s value. If, for example, we would simply assign a value to a variable, say MYVAR=”this is my variable” and we would then issue echo $MYVAR, we would see that the variable’s value will be printed. However, try to make a simple script which would echo it, for example:

#!/bin/bash

echo $MYVAR

And then run it e.g. bash myscript.sh – you will see that the value is lost, not visible in the script. So this is where export is useful, because it will make any further script or application “see” the variable. When we invoke the man command, it will need to see the values for our LESS_TERMCAP variables.

More color schemes

Here is another color scheme:

export LESS_TERMCAP_mb=$(printf '\e[01;31m') # enter blinking mode
export LESS_TERMCAP_md=$(printf '\e[01;38;5;75m') # enter double-bright mode
export LESS_TERMCAP_me=$(printf '\e[0m') # turn off all appearance modes (mb, md, so, us)
export LESS_TERMCAP_se=$(printf '\e[0m') # leave standout mode
export LESS_TERMCAP_so=$(printf '\e[01;33m') # enter standout mode
export LESS_TERMCAP_ue=$(printf '\e[0m') # leave underline mode
export LESS_TERMCAP_us=$(printf '\e[04;38;5;200m') # enter underline mode





Samsung Galaxy S3 gets an early firmware upgrade

The best-selling Samsung Galaxy S3 handset has received its first over-the-air update, with UK users reporting a pair of firmware downloads.
The Android 4.0 device is not experiencing any issues, to our knowledge, but that hasn't stopped Samsung pushing out updates promising "Improved stability" and nothing else.
The 31.7mb download can be installed over Wi-Fi or 3G.
Slashgear is reporting, following the completion of the initial firmware update, that users are being prompted to download another smaller 15mb file, which also promises improved stability.

Taking care of business (TCOB)

The updates suggest that, even with no complaints from an already sizable userbase, Samsung may have spotted something its not completely happy with.
The company has enjoyed some incredibly good, almost Apple-esque feedback from users and critics, so it's good to see it staying on top of matters to ensure that remains the case.
If you haven't been prompted to download the upgrades yet, you can get them by visiting the software updates page within the Android OS settings menu
And, if you're still weighing up whether a 4.8-inch smartphone is really for you, check out our Samsung Galaxy S3 review.

Diablo 3 real money auction house has launched in the Americas


 
Real-Money-AH-1
It is now possible to spend $250 of your hard-earned cash for something called a Horadric Hamburger, with the Americas region launch of Diablo 3′s real money auction house.
Currently, the maximum bid and buyout that can be set on any one item is $250, and there are plenty of items priced at that already. Since Blizzard takes a $1 cut on every successful auction, the minimum is $1.25. Players who want to buy and sell using a Battle.net balance are, understandably, required to attach a Battle.net authenticator to their account. Other options include using a credit card or linking a PayPal account.
Equipment sales come with a $1 deduction (taken by Blizzard from the sale amount). Sales for anything else—like gems, crafting materials, and gold—take a 15% deduction instead of the flat $1, presumably to avoid loopholes of selling those commodities in large stacks. Gold must be sold in quantities of 100,000 or more.
Any money made on the auction house is subject to a 15% withdrawal fee if you want to put it anywhere besides the Battle.net balance (which can be used on the auction house, to pay for WoW subscription time and pets, or anything else directly linked to your Battle.net account).
We have no word on when the real money auction house will be available in other regions aside from “the near future.”
“We are rolling out elements of the real-money auction house separately to ensure all of our players have the smoothest possible experience,” Blizzard claims. “We’ll have more information on the availability of the European real-money auction house and the remaining Americas currencies soon.”
You can read all the technical and financial details of the auction house on the official Diablo 3 site.

Tuesday, June 12, 2012

Diablo 3 cheaters will get perma-banned

Diablo 3 thumbnail
A post on the official Blizzard blog has appeared, reminding Diablo 3 players that they could get permanently banned for using hacks, cheats or exploits.

“We strongly recommend that you avoid using any hacks, cheats, bots, or exploits,” say Blizzard, sternly. “Suspensions and bans of players that have used or start using cheats and hacks will begin in the near future.” The post reads like a formal first warning for players who might be using extra-client features to get ahead. If you are, and you like your Diablo 3 battle.net account, you should probably stop.
The suspensions and bans will begin in the “near future.” It’s probably something to do with the delayed release of the real-money auction house, which is due to hit European and US servers soon. That’s serious business which, as reported on RPS, will require you to have a Battle.net Authenticator or Battle.net Mobile Authenticator attached to your account.

Monday, June 11, 2012

SystemRescueCd 2.8.0

SystemRescueCd 2.8.0, a Gentoo-based live CD with specialist utilities for data rescue and disk management tasks, has been released. What's new? "Updated standard kernels to long-term supported Linux 3.2.19 (rescuecd + rescue64); updated alternative kernels to latest stable Linux 3.4.2 (altker32 + altker64); fixed USB installer script for Linux: usb_inst.sh; updated GPT fdisk to 0.8.5 (fdisk utility for GPT partition tables); updated FSArchiver to 0.6.15 to support recent features in Btrfs and ext4 file systems; updated firmware files in the initramfs from Linux firmware 20120502; Updated DBAN to 2.2.6 (hard drive disk wipe and data clearing program); updated GRUB 2 bootloader to 2.00beta6 (GRUB 0.97 is also provided); updated list of kernel modules to put in the initramfs (storage and network); do not attempt to find sysrcd.dat on extended partitions." Here is the complete changelog. Download: systemrescuecd-x86-2.8.0.iso (379MB, MD5).

SolusOS 2 Alpha 3

Ikey Doherty has announced the availability of the third alpha release of SolusOS 2, a Debian-based Linux distribution featuring a highly tweaked GNOME 3.4 desktop: "The SolusOS team is pleased to announce the release of SolusOS 2 alpha 3. This release uses the GNOME Classic Desktop Environment 3.4 (not fallback), which is heavily tweaked to behave and look the same as GNOME 2. Please note that this is a development release and is not intended for use on production machines. What’s different about SolusOS’s GNOME? In SolusOS 2 we will be using GNOME 3.4, which in its current state features a largely unusable fallback mode. We decided to patch various parts of GNOME to make our implementation look and act identically to our GNOME 2 setup seen in SolusOS 1. This has been done in a way that will ensure 100% upstream compatibility." Read the full release announcement for a list of main packages and known issues. Download: SolusOS-2-A3.iso (945MB, MD5).