Wednesday, July 13, 2011

Two noteworthy commands in Linux to "reverse" the lines

I always appreciate the small and powerful command-line tools which are designed for Linux. Today, I was looking for a command to reverse the order of lines in a line. First, I came a cross rev. This command only reverses the order of characters in each line of the given stream.

After that, I found tac command. This command did the job very well as I expected. It is also able to concatenate several files and accepts regex sperators.

Wednesday, June 15, 2011

Two Empathy IM Tricks

 
Debian Squeeze has two problems with default configuration of Empathy IM.

1- It doesn't allow autoconnect on start of application. Each time, you need to disable and enable your account to be able to connect to the chat server. By using the following technique, you can resolve this issue:

Open gconf-editior. In apps/empathy, untick 'use_conn'. That's it!

2- It doesn't support several chat protocols by default. To add more, just install telepathy-butterfly and telepathy-haze using the following command:
sudo aptitude install telepathy-butterfly telepathy-haze

Sunday, June 12, 2011

Dark background for ViM in xterminal

vim has a white background in x-terminals. By adding the following line to ~/.vimrc, you can change it to black:
highlight Normal ctermbg=Black ctermfg=White

Friday, May 20, 2011

Getting Current Directory In Java

To get the current directory address, these two methods are useful:
  • new File(".").getAbsolutePath();
  • System.getProperty("user.dir");
 Thanks to Java-Forums.

Sunday, January 2, 2011

How to make SunOS interface behave simillar to the Linux interface?

As anyone who has worked with Unix machines like Solaris or SunOS may know, these machines are intractable at the first time. With the following tricks, you can change their interfaces to behave just like Linux machines.
Add the following lines in .inputrc file in your account:
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert

As the comments reveal, these lines let you to use delete/insert/home/end keys as usual.

SunOS doesn't have any ls with output color support. It seems that only GNU ls support colors. You can download the binary/source of a program called colorls from here and use it in your system. At that page you can find the instruction of installing that program under TCSH. If you are using Bash shell, add the following lines to your .bashrc (I copied the colorls in the root of my home directory):
export LSCOLORS=6x5x2x3x2x464301060203
alias ll="~/colorls -GCFkAl"
stty tab0

To have a colorful command prompt, add the following line to your .profile file:
if [ "$PS1" ]; then
    PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
fi


P.S.: I used these configurations on SunOS 4.1.

Thursday, April 8, 2010

Fix the encoding of the Linux in text mode

You may found that some Linux text programs cannot work with UTF-8 (unicode) encoding. For example Midnight Commander (mc) has a lot of problems. Also text configurations tools in Debian have a lot of problems with unicode.

I found that we can change the unicode to en.US ISO to solve these problems by running this command:
dpkg-reconfigure locales

Sunday, April 26, 2009

Note in batch files

There is a tricky difference between commands run in console and commands reside in a batch file. The typical example is the variable definitions. Compare these 2 cases:

Correct in console
: for %i in (*.exe, *.dll) do cmd.exe %i
Correct in batch file: for %%i in (*.exe, *.dll) do cmd.exe %%i

Batch file needs double %.
Special thanks to TechRepublic.