Software As She’s Developed

Mahemoff’s Podcast/Blog – Web, Programming, Usability from the Author of ‘Ajax Design Patterns’ (AjaxPatterns.org)

Software As She’s Developed header image 2

SSH Tip: Remember Last Path

February 14th, 2008 · 5 Comments · SoftwareDev

ssh, Unix

Lately, I’ve been living dangerously and doing a lot of coding on the live server, via ssh. This is all proof-of-concept stuff at Ajaxify. The reason I’m coding live is that it’s all widget development and it’s just easier that way, since environments like iGoogle and Facebook need to reach my apps live, in order to test the app. None of the alternatives take my fancy: open up a port into my development PC (difficult due to dynamic DNS and less secure); upload code each change (slow even if it’s fully scripted); use Shindig on my local machine (unreliable as Shindig is new and in rapid growth mode).

So I’ve been ssh’ing and no matter how many times I’ve tried, I can’t remove ssh timeout, so I sometimes get timed out. So anyway, I wanted an easy way to remember the most recent directory I was in, each time I log back in. This is it – in my .bash_profile:

function cd { builtin cd $1 ; pwd > $HOME/.path_history; }
cd cat $HOME/.path_history

Tags: ·

5 Comments so far ↓

  • David Snopek

    I second Miguel’s statement about “screen”. It will change your life.

    First, imagine having several terminal sessions open in a single SSH connection that you can switch between at any time. Second, imagine getting disconnected and being able to log back in and reattach to your screen session and getting all those terminals back. Even ones with interact programs running in them (ie. vim) will be in exactly the same state as when you left.

    Cheers!

  • Jonathan

    Try this option to ssh:

    -o ServerAliveInterval=60

    This sends a message inside the encrypted channel every 60 seconds, keeping the connection alive to servers who may be disconnecting idle ssh sessions.

  • mahemoff

    Thanks guys.

    @Miguel, @David – you’re right about screen. As I think I blogged at one point, “screen” was banned at uni due so I never got into it. I know I really need to.

    @Jonathan Good tip. I’ve only tried tweaking sshd on the server. Hopefully that param will do the trick…

  • Kevin

    Screen banned? Your uni must not have been teaching “how to work with unix”.

    Check out autossh + screen as well. I’ve set it up with my lappy, and as I move networks, locations, cities, my sessions are always set up just how i like them.

Leave a Comment