cloning xterms in wmii+ruby
[ link: 20070112131252 | tags: ruby desktop bash wmii | updated: Fri, 12 Jan 2007 14:29:41 ]
I have recently added a few things to by wmii+ruby configuration that I wanted to share. These are:
- start a program in a given view from bash prompt (authored by Dave O'Neill)
- start a program in a given view using
Alt-Shift-p(authored by Jean Richard) - start an xterm in a given view using
Alt-Shift-Return - cache directory changes in a view, start an xterm in the view's last directory using
Alt-Apostrophe
shell commands
[ link: shell-commands | tags: bash linux | updated: Fri, 20 Oct 2006 15:58:48 ]
I saw this blog post by Debian's Florian Ragwitz, and ran my own list of most commonly used shell commands. Here they are...
history |awk '{print $2}'|awk 'BEGIN {FS="|"} {print $1}' | sort | uniq -c | sort -r | head -15
627 git
266 vim
98 cd
76 grep
69 ls
63 gitk
60 ssh
51 sudo
47 vv
47 apt-cache
40 cat
34 make
33 patch
30 rm
25 man
generating html colourized sourcecode
[ link: generating-colourized-source-html | tags: vim html bash | updated: Sat, 07 Oct 2006 15:46:41 ]
I wanted to have vim colouring of source files in html format. There is Text::VimColor perl module, but it's not in Debian.
Vim has a :TOhtml command (see :h syntax). I wrote a tohtml shell script to solve the problem using :TOhtml. And yes, the html was generated with itself.
bash vi editing mode
[ link: 20040326082602 | tags: bash vim | updated: Sat, 07 Oct 2006 15:46:33 ]
For a few years now I've been using vi editing mode for bash and anything that uses readline. Here is how I've set things up.
In .bashrc I use the following to enable vi editing mode:
set -o viThis allows me to type as usual and use ESC to get into vi command mode. Since ESC is so far away I frequently use control-[... unless I feel I need the exercise.
Ok, so the whole ESC and even control-[ sometimes gets tired. For example if I want to search history I would have to push ESC to get into vi-command mode and then be able to push J or K to go through history. I found a way around that by using the 'meta convert' feature of many terminal programs. In xterm, for example, setting the eightBitInput to false will cause xterm to convert all Meta-something key combinations to ESC-something which means that I can push Meta-k to go up 1 in history. It just so happens that all the other terminals I've used have this working already, but anyway, here is the line in my .Xdefaults:
xterm*eightBitInput: falseNote that once you push Meta-something you are in vi-command mode so to go up by two lines in history you would use Meta-k k, or use J & K to go up and down as you wish. everything else
Many programs use readline, as bash does, to present a command line to the user. In particular I wanted to get lftp, and others, to use vi editing mode as well. For this I set the following in the .inputrc file:
set editing-mode vi
set keymap vi
set convert-meta on
Now when I start up lftp, I can use vi editing just like in bash.
making tab completion more advanced
I noticed that the vi editing mode in bash has much fewer commands defined then the emacs counterpart. The commands are available but just not bound to any shortcuts. Here is a list of extra bindings that I've added to make TAB-completion, which makes bash so great, a bit more useful:
# ^p check for partial match in history
bind -m vi-insert "\C-p":dynamic-complete-history
# ^n cycle through the list of partial matches
bind -m vi-insert "\C-n":menu-complete
The comments give away the secrets of what the commands do. They don't work
exactly like the vi equivalents for completion, but also provide a bit more
functionality.
clearing the screen
Last feature I missed was to be able to clear the screen with control-L, as defined in emacs editing mode. I've added the following to bind the same in vi editing mode:
# ^l clear screen
bind -m vi-insert "\C-l":clear-screen
further reading
Here are a few links that you might find useful:
