My one-man coup against excessive photons (or: inverting your screen colours for fun and profit)

Being a Unix admin, I am naturally opposed to the visible region of the almighty electromagnetic spectrum. One place I have always had trouble avoiding this is on my desktop, or on the web. The majority of applications and websites feature dark text on a light background. This results in my retinas being invaded with light which has no other purpose than to contrast the lack of light of the important bits. Even the theme of this blog follows this ubiquitous tone schema.
Continue reading “My one-man coup against excessive photons (or: inverting your screen colours for fun and profit)”

My one-man coup against excessive photons (or: inverting your screen colours for fun and profit)

Using “grub-reboot” to specify the OS you want to reboot to

I ran into this immensely handy command for specifying which OS you want to boot into on your next boot. You simply run “grub-reboot” and specify the menu item (which can be found in /boot/grub/grub.cfg) you want to boot into.
Continue reading “Using “grub-reboot” to specify the OS you want to reboot to”

Using “grub-reboot” to specify the OS you want to reboot to

Perlisms: Print all lines between two regexes

Time for Yet Another Perl One-liner. I occasionally need to yank out some info between two specific line delimiters from a large file. Good ol’ standard grep won’t suffice in this instance, so it is perl to the rescue.

Here is an example on how to print all ‘Section “Device”‘ sections out of an xorg.conf:

perl -ne '(m!^Section "Device"! ... m!EndSection!) && print' /etc/X11/xorg.conf

This regex range will match the beginning of my device section, and all lines up to and include the EndSection line. The handy thing about this one-liner is that it will match multiple times. In the above example, every “Device” section will be printed from xorg.conf.

Happy perl hacking!

Perlisms: Print all lines between two regexes

Shellisms: Automagically sudo when editing files

I get irritated to no end when I start editing a file in Vim, only to realize I don’t have write permissions to that file. I wrote this little bash function to address that a few years ago. It checks if I have write permissions to the file I am trying to open, and runs the editor in sudo if I do not. It could be cleaner, but it works. Simply toss it into your .bashrc, and enjoy.
Continue reading “Shellisms: Automagically sudo when editing files”

Shellisms: Automagically sudo when editing files

Shellisms: Quickly edit any executable in your $PATH

I often find my self taking a look into the guts of commands I am executing. Instead of taking time digging around for the path, I wrote this little bash function to save me some time:

complete -c vipath # Auto-completes any executables in my $PATH
vipath () {
  FILE=`which $1`
  /usr/bin/env editor $FILE
}

Toss the above in your .bashrc, and you’re off.

vipath update-rc.d # Result: Open /usr/sbin/update-rc.d in your editor
Shellisms: Quickly edit any executable in your $PATH