Time saving tip: Automatically ls when changing directories

If you spend a lot of time in the shell, you may notice a certain pattern when hopping around the filesystem. You “cd” to where you want to go, then immediately “ls” to see what is in that directory. I found myself doing this extremely often, so I decided to cut my typing time down by automatically listing as I cd.
Continue reading “Time saving tip: Automatically ls when changing directories”

Time saving tip: Automatically ls when changing directories

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