1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Change directory w/out changing screen line

Discussion in 'T&T - Aliases' started by mikea, Aug 19, 2013.

  1. mikea

    Joined:
    Dec 7, 2009
    Messages:
    211
    Likes Received:
    2
    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. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    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...
     
  3. mikea

    Joined:
    Dec 7, 2009
    Messages:
    211
    Likes Received:
    2
    I could use either pushd or cd /d, but I use "popd" often enough that pushd is useful. As for the X3.64 escape sequences -- do you have an example in mind?
     
  4. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,970
    Likes Received:
    30
    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.
     
  5. mikea

    Joined:
    Dec 7, 2009
    Messages:
    211
    Likes Received:
    2
    Yep, that works.
     

Share This Page