Neither one nor Many
Software engineering blog about my projects, geometry, visualization and music.
In shell scripting I prefer the Kornshell. A while ago I experimented with "oh my zsh", but I switched back to ksh. Their auto completion for program commands is really unsurpassed (tab completion on program parameters for grep for example). The auto-incorrect however, is quite annoying . There is also a git plugin that visualized the active git branch in the $PS1
prompt. I liked these features and I want to add them to ksh.
I fixed a few things for ksh in my .kshrc
at bitbucket.
My problem with the default behaviour: by default history is globally shared amongst all shells. I tend to work in a screen and do different stuff in each buffer. So it's annoying if stuff from one buffer magically appears in the other buffer.
So what I do is I make sure there is one history file ~/.ksh_history
which contains all history from all shells. When starting a new shell I copy this file into a history file specific for that ("sub")shell, i.e. ~/.ksh_history_files/<shellpid>
. Each new shell does this.
When a shell is started all history files from ~/.ksh_history_files/*
are merged back into ~/.ksh_history
. And the ones that are no longer in use (shells have exited) are removed. This is done with a simple lsof
call.
Commands are processed through a simply ksh function that makes sure all history lines are unique, without changing the order.
Some funny caveats were:
\x81\01
.\x00
character. If you are inside a git clone).
Maybe the oh-my-zsh git integration is more advanced, no idea. Luckily this visualization in $PS1
is very fast.
trigen@Firefly21:/projects> cd smashbattle
trigen@Firefly21:/projects/smashbattle[network_multiplayer]> git branch
master
* network_multiplayer
trigen@Firefly21:/projects/smashbattle[network_multiplayer]>
Fixed with a simple alias around cd provided by /usr/share/ksh/functions/dirs
. For dirs
usage check here.
trigen@Firefly21:/usr/local/src/wxWidgets-3.0.0> cd <<<< this didn't work on Ubuntu 13.10 anyways.
trigen@Firefly21:/home/trigen>
The browser is assumed to be "chromium-browser" (sudo apt-get install chromium-browser).
gi dan flavin
is opened in a new chromium tab.
i <url>
- open url in browserg <search terms>
- search with google.comgi <search terms>
- search with google imagesgv <search terms>
- search with google videosgnl <search terms>
- search with google.nlgs <search term>
- search google scholarw <search term>
- search wikipediawa <search terms>
- search wolfram alphayv <search terms>
- search youtubey <search terms>
- search yahooyi <search terms>
- search yahoo imagesyv <search terms>
- search yahoo videosimdb <search terms>
- search imdbh <search term>
- search hyperdictionaryv <search term>
- search vandale (dutch dictionary)Usage example: Open run menu (ALT+F2
). Then type gi dan flavin
to get the example result from screenshot.
I had to abandon my pure-ksh-functions approach to make the launcher commands available everywhere.
So you have call install_launcher
as root to install the shortcuts as scripts in /usr/local/bin/
.
Ubuntu does not respect shell functions in run unfortunately.