Change directory w/out changing screen line

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
This falls into the realm of complete frivolity, but oh well. : ) For whatever reason -- the origin of this neurosis is lost in the mists of time -- I like to change directories and stay on the starting screen line. So after puzzling over how to do it for quite a while -- an alias, which I call "SameLine":

pushd %1 %+ screen -1 0 %+ drawhline %_row 0 80 0 %_bg on %_bg %+ screen -1 0

Then for switching to C:\batch, for example, another alias ("b"):

b=SameLine c:\batch

Does what I want unless the cursor is on the last screen line when the command is given.

I'm sure that a few years of therapy would cure me of this same-line-on-screen obsession, but once again: oh well.
: )
 
#2
First, pushd is not the same as cd/d - it's really useful on the very rare occasion you want to go back into directories in reverse order of their last use. In fact I found myself often cycling through 3 or occasionally 4 directories.

You can easily wrap the CDD command into an alias which uses X3.64 escape sequences which work regardless of screen width to keep the cursor on the same line as before...
 
#4
Try this one.
Code:
alias sl `echos ^e[%_row;1H^e[K^e[1A & pushd %1`
It should change directories without changing lines EXCEPT when on line 0.

Note that <ESC>[K (not erasing the character at the cursor) but that should be OK since a new prompt should replace the old (almost erased) one.