Rapid fire shell coding :-)

Well, since Friday night, I have been pretty steadily working on my ~/.sh infrastructure. I started by hooking up alice to sal1600’s monitor (22″), keyboard, and rat. Since I rather distaste how the GNOME/Ubuntu has been acting late: I also took the libtery of adding my xmonad.hs file to git, then ditching GNOME for a pure XMonad session. As I use programs that need a system tray to really be useful enough to me (e.g. pidgin), I’m using fbpanel: good old staple.

For a little while I experimented with making the inactive windows transparent, this works pretty great, but rather interfers with my custom xterm wrapper script that sets my terminals ocupacy: the propteries set by transset-df get lost :-(. Looked at some other terminal emulators supporting transparency, besides gnome-terminal and rxvt-unicode. Sakura seems to be the best bet, and evilvte almost excellence (better to compile from source then using the .deb). In the end, I just switched off the fancy effects, since most of the time I am using a terminal or reading text anyway.

Next up was figuring out how to use XRandR to manually configure my displays. Better still, I wanted to extend my ~/.sh and X session infrastructure to auto-magically configure itself to Do What I Want when I launch a session when hooked up to an external monitor. For architecture and convience, it can also be run as a shell script, thus supporting a sort of hot plugging. So right now, if I hook up to say my 22″ widescreen and let alice do it’s magic configuration: after I login, I will be working off the big screen, so I can ignore the 10.1″ little one :-). This isn’t without a few warts though, namely if I go hotpluggy with it, fbpanel needs to be restarted in order to render on the new primary display (I just switch off the netbooks display), and pidgin becomes confused on where to render notifications (oi) with how it’s setup in the default Ubuntux way. Oh, and hardware issue being that the touch pad makes the cursor jiggly should I close the lid lol. The performance is also noticably slower on 1980×1080 but works very snappy. I really am inpressed with this sweet little ASUS.

I then pretty much went about refactoring bits and pieces of my `sh services environment`, going so far as to create a GNUmakefile that I can use to help set things up whenever rigging a clone on a new install. Being lazy, I also finally moved ~/sw/sh from Dropbox to git. Generally I use bin for local binaries, sh for portable scripts, and sh.local for things specific to the system. Usually odds and ends that reflect a very specific setup.

Over a dozen commits later, I like the result pretty well. The only problem is, the difference between the 20″ screen at work and this 22″ screen, I now have so much screen realestate that I don’t know what to do with it LOL. In Windows, most of it just goes to waste for want of XMonad.

$MYVIMRC

My current ~/.vimrc file. The {{{ & }}} mark the locations of folds, I elected to ues folding marks for my rc file. And when I have time to read how, I probably will set it to allow sectional jumping.

In short form, the file ensures that Vim does not read my .exrc file, does not try to be strictly vi compatible. Auto reads changes to files, keeps files at 80 char width (see tw), make for a more comfortable movement pattern near EOL. Yank into the clipboard, enable syntax folding on new files (my preference for sources), DOS EOL for new .txt files. Set somes sizes, enable my ‘HUD’ ^_^, turn on a nice colour scheme, and syntax highlighting. Set fonts, and a few useful keymaps. :help <option> generally works for looking things up in the manual (help can be shortened to he. with no sexist intent.)

"Terry M. P***** personal vimrc file

" vim: set ts=6 sw=6 expandtab foldmethod=marker foldcolumn=1 foldlevelstart=99:
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" WARNING !!!
" This file must have UNIX end of lines to avoid errors when starting
" under unix. Use the pdos2unix and punix2dos sh scripts to convert or
"
" perl -p -e 's/n/rn/' inputfile > outputfile # UNIX to DOS
" perl -p -e 's/rn/n/' inputfile > outputfile # DOS to UNIX
"
" on the command line
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Abstract
"
" Editing Preferences - set options related to editing tasks
" User Interface Preferences - set options related to appearance
" Keybinds & Commands - mappings / created


"""""""""""""""""""""""""""""""
"Editing Options {{{
"""""""""""""""""""""""""""""""

"Don't be VI compatible - Keep this at top of file !
set nocompatible
set noexrc

"automatic re-reading of changed open files
set autoread


"ingore case when searching
set ignorecase

" Use the system clipboard as the default register
set clipboard=unnamed

"Buffer related {{{
"Allow backspacing over everything in insert mode
set backspace=indent,eol,start
"Allow to go one space past EOL
set virtualedit=onemore
"Allow left/right movement at EOL to move to start of next line
set whichwrap=hl<>
"Wrap text at n chars with a line break
set textwidth=80
"set wrap
set linebreak

"Folding
if has("gui_running")
set foldmethod=manual
set foldcolumn=0
else
"Use sytanx folding in console mode
autocmd BufNewFile,BufRead *set foldmethod=syntax foldcolumn=1
endif

"}}}

"Size stuff {{{
"Tab length and shift lengths
set tabstop=8
set shiftwidth=4

"Set min # of spaces for numberwidth. It grows as needed
set numberwidth=2

"Set tab menu 0=never, 1=when more then one, 2=always
set showtabline=1

" Start with folds open
set foldlevelstart=99

"}}}

"File related {{{

"Set prefered line file formats
set ffs=unix,dos,mac
"Enable filetype detection
filetype on
"Turn off ft plugin and indent
filetype plugin off
filetype indent off

" Create new.txt files notepad ready
autocmd BufNewFile *.txt set ff=dos

"Enable syntax highlighting
if &t_Co > 2 || has("gui_running")
syntax on
endif

" Highlight strings inside C comments
"let c_comment_strings=1


"}}}

" }}}
"""""""""""""""""""""""""""""""
" Keybindings {{{
"""""""""""""""""""""""""""""""

"Maps {{{

"Use the ";" as a duplicate of ":" makes life so much easier
"for some odd reason it cannot be followed with a comment on it's line!
:nma ; :

"F1 turns on spellchecking in current buffer
map :setlocal spell spelllang=en_us

"F2 turn on line numbering
map :set number

"F3 turn on self indenting magic
map :set smartindent autoindent

"F10 rids us of ^M after carriage returns
map :%s// /g

"}}}

"}}}
"""""""""""""""""""""""""""""""
"User Interface Options {{{
"""""""""""""""""""""""""""""""

"Always show the status bar with file name e.t.c.
set laststatus=2
"Show %of file in statusbar
set ruler

"Command line completion lists possible matches
set wildmode=list:full

"Start with mouse support
set mouse=a
"Hide the mouse when typing text
set mousehide

" Dependant on GUI on/off {{{
if has ("gui_running")
"Set colo and options
colorscheme denim
" Set 'go' to:
"autoselect, console dialogs, tabpages, icon, menubar, show grey menu
"items, tearoff menu items, Toolbar, always right scrollbar.
set guioptions=aceimgtTr

"Make pointer an I-Beam in insert mode
set mouseshape=i:beam
"for spellchecking
set mousemodel=popup_setpos
"set cmd line size
set cmdheight=2

"Set windows specifics
if has("win32")
"Windows font
set guifont=Fixedsys:h7:cANSI
"Set x11 specifics
elseif has("x11")
set guifont=Fixed Semi-Condensed 13
set columns=80
set lines=35
endif
else
"set colors for terminal
colo advantage
"set cmd line size
set cmdheight=1
endif

"}}}

" }}}

vimrc

Post best viewed from here

Ahh what a day. I’ve spent most of my time ether on the forums or in my beloved editor of choice (vim). I desided for some odd reason to rewrite my vim resource files. I’ve more or less completed my ~/.vimrc file and will worry about my ~/.gimvrc file later. Really I rarly use the GUI off win32. I basically like using vim in konsole because I can quickly step in and out of editing, ether by forcing vim into the background (control+z, type fg to return to it). Yet because cmd.exe is the worst terminal I have ever used, poor if any support for cut, copy, and paste. Ignores the mouse for the most part and Windows has the tab completion of a fart in the wind. I’m kinda getting used to zsh’s after using tcsh so much hehe.

Heres my vimrc file so far, edited for a few things. The syntax is about as simple as a shell script or “vim script” but the ” double quote works like the # and // comments in most languages. White space it doesn’t care for but it does care about line endings. Since I share most things between Windows XP, PC/Free BSD, and GNU/Linux + several computers I have to be portable in many ways. I started the file on Windows with my file format set for Win/DOS end of lines (:set ffs=dos), vim detects it and uses whats there. I usually set mine as “ffs=dos,unix,mac” so I don’t have to convert my files End of Lines (EoL) when I send some one a text file. If I use UNIX eols theres no carriage returns in Notepad, it’s too dumb to figure it out unlike many many other editors. Sad through is you can always count on some one to have notepad or a simular editor. Gnomes editor and KDE’s KWrite are actually rather nice though. When I tried to run my now complete vimrc on PC-BSD I got a zillion errors and I new I didn’t screw it up that bad, infact only one entry was wrong. I quickly figured out it must have been the line feeds, the fact that I had just setup a keybind to strip off the pesky ^M’s you get in some files helped hehe. I couldn’t find any quick ways to convert the EOLs so I looked them up in Wikipeda and found a way to do it with pearl, I now have a pdos2unix and punix2dos script to do the job when given an input file name and an output file name.

I’ve been told customizing Vim can be bad b/c of having to work with standard vim/vi but I’m a fruit -> If I want Vim I call vim and if I want Vi I call vi. FreeBSD uses nvi for vi, not vim like some GNU/Linuxes do. If some Linux Distro doesn’t make vim start as vi compatible without special changes it’s not my problem. I learned to use vim with just the example vimrc file. After that using Vi was easy after an hour or two. I also remember which I’m using by the fact that I call vi as vi and vim as vim + the status line I keep around.

Lines that start with two “‘s are comments just for this post

"Terry M. P***** personal vimrc file

"""""""""""""""""""""""""""""""
"Editing Options
"""""""""""""""""""""""""""""""

"Don't be VI compatible - Keep this at top of file !
set nocompatible
""Setting vim to be vi compatible makes changes to make it more pure Vi, I don't care for
""this as this is VIM not VI, if I wanted a pure Vi clone I'd use one.

" allow backspacing over everything in insert mode
set backspace=indent,eol,start
""This makes life a lot easier, just trust me.

" Wrap text at n chars with a line break
set textwidth=80
set wrap
set lbr
"" To keep console portability I used to break my lines around 76~78 char
"" I'm trying this to make Vim more like other editors. Out of the box when you write
"" a line two long for the screen it continues on the line below and is numbered as one
"" line. With these settings it breaks them like most other editors at my specified
"" 80 chars. Not sure if I will keep it but worth a test. -> Prolly good for Vim newbies

" Use spaces instead of tabs
set expandtab
set tabstop=6
""I generally like spaces and monospace fonts more for indentation and coding.
""I do like using tabs for manually aligning data in a table in ASCII.

"set min # of spaces for numberwidth. It grows as needed
set numberwidth=2
""This keeps down the size used for the thing /w the line numbers. Defualt is 4.

""""""""""""""""""""""""""""""
"Tabbed Editing
"""""""""""""""""""""""""""""""
set showtabline=1
""Only show the list of tabs when theres more then one. 2=always, 0=never

"set prefered line enders
set ffs=unix,dos,mac
""Type :help ffs for more info, can be set in GVIM via options menu.
"enable filetype detection
filetype on
"turn off ft plugin and indent
filetype plugin off
filetype indent off

"Enable syntax highlighting
syntax on
"" Syntax highlighting is very good, does stuff like making comments blue, keywords green
"" strings red e.t.c. Very nice for markup, scripting, config files, and programming.

"""""""""""""""""""""""""""""""
" Keybindings
"""""""""""""""""""""""""""""""

"Use the ";" as a duplicate of ":" makes life so much easier
"for some odd reason it cannot be followed with a comment on it's line!
:nma ; :
"" I personally think typing ; instead of pressing shift + : is the way it should be

"F1 turns on spellchecking in current buffer
map :setlocal spell spelllang=en_us
"" I only want spell checking for certain files so this lets us turn it on when we want it
"" and just in the current buffer (like file)

"F2 turn on line numbering
map :set number
""I don't want line numbering unless it's a source file or a big document. Pressing this
"" key we turn it on when wanted.

"F10 rids us of ^M after carriage returns
map :%s/^M/ /g
""You have to make the ^M by pressing control+v control+m for this to work.
"" Some times you'll get pesky ^M at all the EOLs and it annoys me - strip them

"""""""""""""""""""""""""""""""
"User Interface Options
"""""""""""""""""""""""""""""""
"Always show the status bar with file name e.t.c.
set laststatus=2
"" 0=never, 1=only if more then one file/buffer/tab
"Show %of file remaining in statusbar
set ruler
"" I use thse two this b/c I like knowing what line/column I'm on un obtusivly + file name
"" and how far into the file overall I am.

"""""""""""""""""""""""""""
" MOUSE
"""""""""""""""""""""""""""
"Start with mouse support
set mouse=a
"Make pointer an I-Beam in insert mode
set mouseshape=i:beam
"Hide the mouse when typing text (GUI only)
set mousehide
"" I'm used to being able to scroll around with my mouse wheel :)
"" Try :help mouseshape to look at what you can do with the mouse pointer. X11 supports
"" more options then Windows.

"""""""""""""""""""""""""""""""
"General Preferences
"""""""""""""""""""""""""""""""

"Command history
set history=50
"" Remebers the last 50 commands entered via :command

"automatic re-reading of changed open files
"set autoread
"" Gotta test this, basically if you edit in vim and edit with another app. It will try
"" to re-read the file.

" Switch on search highlighting - use :noh to turn it off after a search
set hlsearch
""highlights all matches to a /search

"ingore case when searching
set ignorecase
"" just like grep -i "I guess"

"set cmd line size
set cmdheight=2
""This makes the command line at the bottom, where you see the ":" when entering commands
"" be 2 lines high. Not really important IMHO

__________________________________________________

Some changes I plan, if it’s starting with the GUI I’ll have it set it so I can right click on miss spelled words and correct them. you can move the cursor to the word and press z= for a list of corrections, and use ]s and [s to search forward/back. Some times I just scroll with the mouse when proof reading so this helps. You can do a :set “mousemodel=popup_setpos” to get it after you turn on spell checking. I want to set it up so I can quickly convert a files format between DOS and UNIX via F11 and F12, should be possible.

I’ve downloaded a few things from http://www.vim.org/scripts/ that I want to toy with. One was a pack of 140 themes for gvim gotta sort that hehee. Another was a Matrix screen saver. It’s pretty nice if you speed it up but on my system it makes me use like 50~60% CPU judging by GKrellm2 my favorite GTK Krell system monitoring app.

One of the reasons I love vim very much is it’s very relaxing to us. Since I play games often as I can get a good tactical one /w my team mates. I do plenty of running. Once the tangos know your there you gotta get moving quickly (Dynamic). So in the intertests of moving as fast as is safe and doing proper B and CB entries (Bang & Breach Bang clear). I have my pinky jutted out to hold shift many times. B/C Usually I don’t run all the time, I try to sneak about unless I plan on being Dynamic. So that and using my pinky to make capital letters puts alot of strain on my, now couple that with Escape Meta Alt Control Shift (EMACS) style editing. When I use my pinky to deal with capslock (hate that key), shift, control, z, and Windows. It’s nice not to have to strain my fingers or wrists. I find using vim very comfortable for long edits. It’s also so dang effective that I can’t stand many other editors. Its like the speed and power of Vi/Vim ruins you for other editors once you learn it. I don’t claim to be no Vim Master or any thing but to me its gotta be the worlds greatest editor. Vi is in the top 10 in my book but Vim >= #1 xD

The only bad thinkg is some times I press # instead of $. The $ key moves to end of line in normal/visual modes. While the * and # keys searches forward and backwards for the word under the cursor. One thing I’m looking at is a C Refernce that can be ran in Vim, might help me write files on Win32 again. Usually I prefer BSD for doing C work because I can quickly look up a routine via the system manual. After all Unix was written in C and so is largly FreeBSD and I’d reckon most of GNU/Linux which is infact made up of many languages afaik.