From confronting VI to a simplified computer life – or how drastically my usage of computers has changed in little over a year
I’ve never considered myself a tweaker or tinkerer, speaking about computers. Sure, I like to configure things to my liking and go through all the settings but not often for visual enhancements. However, time has proven me wrong. As you we’ll see farther down, I ended up changing and configuring most things configurablein an OS, almost from scratch but not for the reasons I suspected.
How it all started: the Vim love story
A year ago, I found myself looking for a good, a real text editor. I was bored of xcode (hadalready given up visual studio built-in editor) and wanted an opensource alternative, and a multi-purpose one (one to write everything from). And only 2 came to my mind! the BIG ones:
- Emacs
- Vim
And thus, I fired up a terminal emulator and gave them a try (both come preinstalled in Mac OS X). 10 min each, the real basics, nothing more: how to write, save and exit a text file.
Emacs looked nice, coming from Richard M. Stallman I wasn’t expecting less (I should say felt, because the looks of a console-based text editor is generally nothing more than the text you are editing), but it was that oldy thing called bI that blew my mind with modes! I got caught by that simplicity which lies beneath the modal design; the fact that you talk to a text editor with verbs and nouns (mandates and objects). Despite “VI VI VI being the editor of the devil” I felt desperately attracted to it.
Since then, Vim has replaced nano as my de facto console editor for small config-files editions and textedit to write simple txt files (’cause yes, I write my to-do lists in txt (their just so easy to share, via sftp, rsync (over ssh for the cypher-enthusiasts), git or so many more) and even some large texts I keep to myself (or not so much as the introduction to an interactive shell I wrote for some friends at university, that i’ll probably publish, though it is more a collection of commands than a real tutorial)) – because I dislike Microsoft word and open office seems over-kill (and it drives resources away from what monopolises my computer: firefox (or should I say “oh how much I hate you” flash)) – when no printing is required (ok, i’ll probably end up writing latex xml from vim and output it to pdf to print docs! but I just haven’t found the right time to start learning it).
I should always remember that before that I had already encountered VI (yes, VI and not vim) while configuring some installs, when it was the only accessible editor (maybe nano too). I was lost back then, I barely knew how to enter interactive mode and always ditched it in favour of nano!
Back to the topic (sorry for that helly amount of digressions, caused by writing directly my thoughts instead of planning the post – which I always intend to do except when I feel I need to get something out (to you and out of my mind) as quick as possible). Vim now drives my computing! I fell in love with its simple design (vi’s but today vim is just the editor hat follows it).
I don’t only mean going modal as much as I can (I should need to try vim zsh/bash modes and vimperator-like plug-ins for everything – firefox, but I also want one for RSSOwl, and Thunderbird if it was my mail client) but the fact that a good use of Vim forces you to stop from time to time to look back at what actions you are doing inefficiently (the ones I get bored, repeating over and over) and write (or catch) plug-ins to replace them.
The time where I see repetitions in every task I do
Get rid of GUI annoyances
All of this is why I moved from using the gui to open an app (menus and icons), to using spotlight,dash,or any text driven launcher, to key combinations! I don’t mean launchers aren’t needed, just that for the 10-15 most used apps I’d rather have key-combinations than: 1.”launching the launcher” 2.typing the app first letters and 3.pressing enter. For more rarely used apps the launcher is great.
Using a gui to look up apps I use even less, that I shouldn’t do; if I open the app that rarely it probably means I don’t need that app and thus shouldn’t even be installed!
The same goes for window management! a full fledged gui is great (i’m a huge KDE fan!) but resizing windows is a very tiring task. I first looked for key-combos to switch between commonly used sizes (full screen, halves, quarters) and ended up shift-it and then spectacles on mac os x (spectacles is just the way to go for that, easier to install and configure, with just the desired options).
That was great… until I wanted to resize the windows to different proportions. It still required to use the mouse and waste and awful lot of time. And now you already know (for those who use them) where I was headed! directly into the awesomeness (don’t get me wrong, awesome wm is not the one I chose – haven’t tried that one) of tiling wms! (Xmonad and dwm are the ones that cought my eye, for their simplicity – in their design)).
I still love KDE, and use it on the desktop (don’t really use it often yet, cause it is slow, slower than my everyday, almost 3 years old laptop – that I will probably rock for way longer if I switch to an SSD and upgrade RAM and OS – i’ll move to an everyday linux install (would go freebsd or even openbsd (which I know almost nothing about it) but wireless drivers forbid me to do so). I would use KDE even more if I could get Xmonad or dwm to run on top of it, like the ‘blu-something’ project that I think got merged back with Xmonad that ran on top of gnome2; right that’s a few years old, cause gnome2… ok, not that crazy old, the latter still is in Debian stable repos!
Automate, automate, and keep automating
Next step in simplifying every day computing scared me at first: scripting to “automate” (not thinking of cron jobs here, just shell scripts, but that is the following step I haven’t reached yet) every-day tasks
The first one that I decided to do is to toggle wifI (and easily as a consequence of it, ethernet) connection.
This is the easiest way I thought to achieve that goal (understand en1
or wlan0
depending on your platform or should I rather say kernel – because kfreebsd Debian or Gentoo have a special place in my heart – though I feel they’ll end up each in a separate jail, ruled by freebsd :P) :
#! bin/sh
if [ -n echo $(ifconfig en1 | grep inactive -o) ]
then
ifconfig en1 down
else
ifconfig en1 up
fi
But this has a problem: it requires root privileges and i’m not really into running as root 24/7. So these scripts are left for my Kali linux vm (now than we can tweak my Bactrack without having to care about repeating everything with every R iteration – I hope ‘aptitude dist-upgrade’ will work without breaking anything when times come). I tried to chown the script to root and chmod 711 (the latter for security purposes… I don’t want any one being able to modify a script to be run by root) but as many of you probably already know, this doesn’t work either.
Two workarounds comes to my mind (although I haven’t tried any), toggling kernel modules instead of putting the interface down (would be wl module for me… the Broadcom one that drive nuts and forbids me to jump straight into FreeBSD with Debian and Gentoo jails to play all day long with the software repos). The alternative would be to build a root job that waits for a file to change or any other input allowed to normal users. That root script would then toggle the WifI interface. The kernel module solution has a big advantage, it can be used for so many different things that are not stoppable otherwise: RS323, keyboard backlight? (maybe not that one as it comes with special keys, screen backlight and some more utilities…) cd/dvd player to reduce battery consumption…
Of course, the objective of any of those type of scripts is to be run with a key-combination (maybe Control-Super-W for Wifi), or at least an alias (for the ones not used so often or dangerous ones).
Talking danger now. Some tasks should remain painful to prevent a bigger damage (please don’t get me wrong, i’m talking computers only here). Here’s an example.
I don’t know the way you use to shutdown (gui doesn’t count, we’re in a light window manager set-up now (ideally a tiling one) not a desktop environment),
I like: sudo shutdown -h now
(I use this command for 2 reasons, I can’t bother remembering halt or poweroff (even if I already know them) because you can do so much more with shutdown! such as adding some delay by changing ‘now’ to ‘+10′ for 10 min, or going to sleep or rebooting instead of halting with -s
and -r
respectively; and I (you may call be what ever you want for that as long as it is stupid, for that) don’t really know the difference between halting and poweroffing (I imagine shutdown does halting the good way because it is multipurpose, although I could be wrong)).
You got my way of thinking, sudo shutdown -h now
this is too long to type. But even if I shut down my computer daily (I do it weekly… sometimes) assigning a key combo is too dangerous for me. I don’t want to risk turning off the computer because I mistyped some capital letter.
In this case, I give aliases some love. I could use, ‘bye’, ‘byebye’, ‘goodnight’ or even ‘sleepwell’ (though I think those too feel nicer for -s version).
Some repetitive tasks that play better with aliases than keyboard shortcuts
An obvious one: updating your machine. Running:
# sudo aptitude update
# sudo aptitude safeupgrade
for those running debian or descendants (apt-get is a good way to do this too, just don’t come near me with a yum update
– just joking, nothing against you Fedora, Red Hat, Mandrake, Mandriva guys – maybe it’s just envy I feel)
# emerge --sync
# emerge --update --ask world
both ways are too long and soon get boring. A simple alias and all of this is done in a breeze (maybe: rotfl
or updateyourselgdumbass
(ok, maybe not, that’s again too long, I don’t want to end up aliasing that for something else, though that would be funny especially with friends that tend to shouldersurf too much) or ‘uptodate)
A last one for pleasure
This is the last key-combo (because it deserves one,(and an aliases for some options too)) and I haven’t written it yet (but I know it is easily doable).
To get you in perspective, imagine yourself in a freshly cooked linux box, (still no gui, frame-buffer only or a light window manager). what is the most shocking thing you face when you just landed there from a desktop environment? there is no automated mounting of inserted drives (I don’t discriminate between usb flash-drives, SD or other cards or even hard-drives with usb-enclosures nor between file systems; which one do you like? still old and maybe not that classy fat, NTFS, hfs(+), any ext flavour or some good looking weirdos (at least in this situation – haven’t found a single external drive in any of those file systems) such as ZFS or Btrfs?)
So what should we do ? (I’m going through this right now :–( ). Write a script to auto-mount a fat drive in a given usb port (maybe it will work recursively for all ports, won’t know until I try to write it) and launch it with an alias. Then what if your drive is not fat? add with a few simple arguments to that script! mountme hfs
or mountme ntfs
. If you, like me and don’t know enough sh scripting to use arguments (or for simplicity), just create separate scripts and substitute the white space with an underscore mountme_zfs
or just remove it mountmeext4
.
Starting with these seems like good idea, you’ll have time later on to figure which ones you use the most and add shortcuts.
If we end up needing to specify the usb port it won’t be much more difficult: mountme1fat
(I would use mountmeX for fat as it is still the most common… :-S or for exfat if you have switched already your flash-drives to that one). the same goes for keyboard shortcuts, adding a 1 or a 2 to a shortcut is a bit painful but I think it is worth not having to type even a short command.
and this was, and still is (will always be, because more things can be simplified), my way to laziness!
It requires a lot a work at first and some commitment but it is very quickly rewarding, so much more when you come back to your computer after a trip to a default gui (such as a university windows box, or a friends’, or a family KDE/gnome/unity box that needed local or remote maintenance (remote is the worse, so painful… especially with a low upload-speed connection)). At least I don’t have go through this again! I just need to keep my dot-files in a safe place forever… (this sentence reads code control ;–) )
PS: as you might have guessed, Debian is my way to go when I feel lazy on linux and need a rock solid packet manager (haven’t lived enough on rpm side of life, except a few weeks to manage my mother’s laptop until I reinstalled an Ubuntu LTS on it because I couldn’t go along with Meego –mainly for the lack of support, ok, maybe I also thought that atom chip could fly a bit higher, even with unity); and I turn to gentoo when I wan’t to all crazy about source (haven’t tried any sorcerer descended distro, (either lunar, which feels a farther descent because it looks more machiny and not so much fairy) with their (I must say it kinda attracts me a little beside sounding a bit foolish) magic casting way to compile. haven’t tried CRUX despite liking the whole idea behind it –remember my affinity to Beasty– though I like so much Gentoo’s USEFLAGS I don’t feel I will ever try to jump to CRUX, not even for a 2 day trial– who knows). Between Gentoo and Funtoo, can’t say. I should try them both for longer but for now I can keep rsync for a while (git is good too, but hey, not yet worth switching).
PS 2: I hope my writing was funny enough (maybe it isn’t at all, and i’m all wrong about my way of blogging) to keep you reading till the end! congratulations if you did! you deserve a price, but I don’t have enough energy reaming to think about one.
PS 3: I just realised I never mentioned how to make key-combos for scripts, but this you will naturally discover while configuring a tiling wm and every one is different. for dwm and Xmonad it comes down to editing the header file and recompiling the binary (sounds awful at first but you can do it with a keyboard shortcut by default in the last releases of Xmonad – or maybe you just don’t need to recompile everything any more, I sincerely don’t remember). In Mac OS X, use Automator services to start shell scripts with a keyboard shortcut that you can assign later from the keyboard configuration panel.
yes, this is slightly meant to be an ever alive-post, making inserts with new tricks and whistles when I come across them.