Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Wednesday, June 5, 2013

Remove string postfix in shell

Can't believe I missed this tip for years (and was using all kinds of ugly workarounds).

To quickly remove a postfix of a string in shell:

test=file.ext; echo ${test%.ext}

On the other hand, if ext is not in test, the original string is returned.

PS: There are some more standard ways to deal with extensions, like

FN=$(basename $1 .tex)

But to deal with a string is more general and has more widely usage.

Saturday, June 23, 2012

Generating latex-style figures using gnuplot

In a figure, it would be nice that the fonts and formula styles are consistent with the main text. For my case, the main text is in LaTeX, and the plot is generated using gnuplot. Here is how to:

Monday, March 26, 2012

Run mathematica commands in emacs

I would like the following feature: When writing a document in emacs (say, a LaTeX paper), I can write the original expression in a comment line, then execute and get the answer. The idea is to send a string from emacs to a shell script, which runs Mathematica kernel

Here is the realisation:

Sunday, December 11, 2011

Taking notes using emacs org-mode

After years of using emacs, it's surprising that I got to know org-mode so late. Better late than never. The first thing I did is to switch to org-mode to arrange my notes, on research, computer technology and life.

My criteria for a good note taker is as follows:
  1. Easy to organize topics / create note
  2. Full text search
  3. Sync a copy to internet
  4. Todo list and other tags in note
  5. Mathematics formula support
  6. Simple item folding and expanding
  7. The editor is stable and feature rich
  8. At best plain text, to access anywhere
With the help of Dropbox and some shell scripts, emacs org-mode is good for all the above aspects: (3) is implemented by putting the note folder into Dropbox. (4) - (8) are the advantages of org-mode or emacs. While here I use some simple shell scripts to implement (1) and (2) on command line.

Saturday, December 10, 2011

Use emacs as a widget

Previously I used yakuake or tilda as a terminal -- press F12 to call or switch back from them. Then an idea comes: why not using emacs for this purpose, and a lot more?

Here is what I have now: press f12 to switch from a pre-configured full screen emacs window and the current window. I can run terminal commands, open frequently used files, take notes and do mathematical calculation (maxima) in emacs. Press f12 again brings me back to the previous application I was using.


The idea is as follows: