[zsh] Print the full command line history

Tags

, ,

I recently moved to using zsh instead of bash. (So, you may expect more of my zsh-related posts). Something that bugged me since the beginning is that when I try to see all the commands used previously using history command, zsh does not list all of them! The correct way to get the desired behavior is to use
$ history 1
in the command line, which literally means start listing from the 1st command in the history file.

Since we are at it, I though it would be nice to post a nice history related function:

h() { if [ -z "$*" ]; then history 1; else history 1 | egrep "$@"; fi; }

If you type
$ h ls
it’ll give you all the history related to the command ls. If it does not follow an argument, then the function just shows normal behavior of “history 1” mentioned above.

[wordpress] Insert source codes in your blog with automatic syntax highlighting

Tags

, , , , ,

In order to do language specific syntax highlighting of your source code, replace “your code goes here” by your actual code:

[sourcecode language="css"]
Your code here
[/sourcecode]

See an example here.

For available language options refer to the link below.

Reference: WordPress Support.

Reference

[cli] Find out success status of a command in BASH/ CSH

Tags

, , , , , , , , , , ,

To know the return value of a command, in BASH run
$ echo $?
and in CSH/ TCSH run
$ echo $status
which will give you the return value (0 or 1) of the last command (the one issued just before the echo).

In both the shells, if the above spits out 0 (zero), it means the previous command was successfully completed, otherwise it’ll give rise to 1 (unsuccessful!) — quite contrary to our concept of 0 being false and 1 being true, eh!

Credit: Oracle Spin.

[cli] Split a huge file into smaller pieces

Tags

, , , , ,

There may be occasions when you may need to split a huge file  into smaller pieces for storage restrictions (or if you plan on sending them piece-by-piece to a friend!):

The following nifty trick (picked up from Commandline-fu) explains how a directory, <dir>, can first be tarred and split into smaller pieces and later rejoined as need arises:

$ tar cf - <dir> | split -b<max_size>M - <name>.tar.

Rejoin later with `cat’ and then extact:

$ cat .tar.* |tar xf -

Credit: Commandline-fu.

UPDATE: Problems with the first line of the code is fixed. This arose in the first place because when I put <dir> in the  raw HTML box, it just ignored it since <dir> is not a valid HTML tag (as if I wanted it to be!).

[latex] Use ``FiNK'' package to include filenames with special characters

Tags

, , , , , , ,

LaTeX throws away an error messages when you try to include a file with special characters (in a LaTeX sense, e.g., hyphen, dot, underscore) in its name into the LaTeX source file. The FiNK package lets you get away with that. FiNK is an acronym for File Name Keeper. It’s not to be confused with the Fink package for OSX, which allows you to download compiled Open-Source binaries using apt-get in the command line from a common repository.

Here’s an example of using FiNK package with the includegraphics command:

\documentclass[11pt]{article}
\usepackage{graphicx, fink}
\begin{document}
\begin{figure}[h]
        \label{fig:figure_label}
        \centering
        \includegraphics[width=\textwidth]{file-name_with_special_chars.eps}
        \caption{The caption goes here}
\end{figure}
\end{document}

(More about includegraphics was posted awhile ago: here and here)

FiNK source: CTAN.

UPDATE: It seems that with MacTeX 2009, the problem  mentioned at the top does not exist anymore (at least my testings say so)! However, I used to have this problem earlier when I’d use the TeTeX package (its development was stopped in 2006 and it has been superseded by  TeXLive) on  my Linux box.

Design a site like this with WordPress.com
Get started