43 votes

I force my shell prompt to the bottom of the screen

Is it just me, or is it weird that every terminal starts at the top-left? After three commands, your prompt stays at the bottom of the screen for the rest of the session anyway.

I added this to my fish_greeting last month. (You could add something similar to .bashrc / .zshrc):

printf "\033[$LINES;1H"

If you want to print a status line or two after this then subtract the number of extra lines:

printf '\033[%s;1H' (math $LINES - 1)
cat /proc/loadavg

It might take some getting used to but it feels a lot more natural. When opening a new window or pane, the prompt is always closer to the previous one so my eyes don't need to move as much.

It's a small subtle thing but I think it is an improvement. Return to teletype.

18 comments

  1. [10]
    GOTO10
    Link
    I once hacked my terminal to scroll the other way around. It's much better for your posture to look at the higher part of the screen most of the time.

    I once hacked my terminal to scroll the other way around. It's much better for your posture to look at the higher part of the screen most of the time.

    13 votes
    1. [9]
      xk3
      Link Parent
      That does sound even better! I wonder how hard this would be to do in a terminal and shell via OSC 133... It looks like it is possible to some degree by just modifying the shell or the prompt:...

      That does sound even better! I wonder how hard this would be to do in a terminal and shell via OSC 133...

      It looks like it is possible to some degree by just modifying the shell or the prompt:

      Apparently Warp terminal has this option called input position, reverse order

      2 votes
      1. [4]
        trim
        Link Parent
        I don't remember Warp having that option, but it's a long old time since I used OS/2. Still have the media here though. It was quite hard to install in a VM for a time, and now I don't even have...

        I don't remember Warp having that option, but it's a long old time since I used OS/2. Still have the media here though. It was quite hard to install in a VM for a time, and now I don't even have the hardware to do that.

        4 votes
        1. [3]
          tomf
          Link Parent
          not OS/2! https://www.warp.dev/ :) I don't miss OS/2 but I think about it a lot.

          not OS/2! https://www.warp.dev/ :)

          I don't miss OS/2 but I think about it a lot.

          4 votes
          1. [2]
            trim
            (edited )
            Link Parent
            Haha, right! Man I loved OS/2. It wasn't that long ago it was still running a decent chunk of ATMs in the UK. Also, cool terminal there. Mac version too, I'm trying it out now. Cheers! Edit: that...

            Haha, right! Man I loved OS/2. It wasn't that long ago it was still running a decent chunk of ATMs in the UK.

            Also, cool terminal there. Mac version too, I'm trying it out now. Cheers!

            Edit: that didn't last long. My Mac blocked a strange outbound connection then when I said I didn't want an account, it hung. Oh well.

            5 votes
            1. tomf
              Link Parent
              oh yeah, that was absolutely not an endorsement of Warp --- I am ride or die with iterm2. Wild that ATMs were running OS/2. ATMs are often well behind on software anyway, but that is waaaaaaay behind.

              oh yeah, that was absolutely not an endorsement of Warp --- I am ride or die with iterm2.

              Wild that ATMs were running OS/2. ATMs are often well behind on software anyway, but that is waaaaaaay behind.

              3 votes
      2. [4]
        Asinine
        Link Parent
        I'm trying to figure how this works with mine... I learn about the prompt every time I update it (which hasn't happened in ... dang, my timestamp got wrecked trying to implement this with .bashrc....

        I'm trying to figure how this works with mine... I learn about the prompt every time I update it (which hasn't happened in ... dang, my timestamp got wrecked trying to implement this with .bashrc. But I believe it's been at least 2-ish years based on the last custom timestamp).

        I tried a few options that wrecked the said backup timestamps apparently, and I can't figure how to implement something like this. I asked AI and didn't get any help... so any "once hacked" insights you'd like to share, I'd be greatly appreciative! (And, I would prefer to do them myself, as xk3 pointed out to each their own :)

        I'm using Kitty and the custom bit I've implemented (heavily influenced/created by bashrcgenerator.com) is

        export PS1="\[\033[38;5;11m\]\A\[$(tput sgr0)\]\[\033[38;5;15m\] \u\[$(tput sgr0)\]\[\033[38;5;46m\]@\[$(tput sgr0)\]\[\033[38;5;39m\]\h\[$(tput sgr0)\]\[\033[38;5;46m\]:\w\[$(tput sgr0)\]\[\033[38;5;15m\]\\$ \[$(tput sgr0)\]"```
        
        1. [3]
          xk3
          Link Parent
          I think you meant to reply to @GOTO10 but I'm curious about this too. The information on this page explains why it is not a simple thing to have done but I also don't want to discourage you from...

          so any "once hacked" insights you'd like to share

          I think you meant to reply to @GOTO10 but I'm curious about this too. The information on this page explains why it is not a simple thing to have done but I also don't want to discourage you from playing around!

          However, my advice is this: use printf first instead of trying to get it right the first time. It's easier to run printf a bunch of times than it is to recover from a broken $PS1

          I also use Kitty and I wonder if something like this wouldn't be possible to implement inside of a Kitty kitten. If not, it might be easier to hack a simpler terminal like st or foot

          1 vote
          1. [2]
            Asinine
            Link Parent
            Yep, meant GOTO10 oops! I haven't actually messed with my kitty.conf at all, though the kitten thing is interesting. I'll take a look at it!

            Yep, meant GOTO10 oops!
            I haven't actually messed with my kitty.conf at all, though the kitten thing is interesting. I'll take a look at it!

            1. GOTO10
              Link Parent
              This was a long time ago, we were bored in the office (remember those?), and just downloaded the source of a simple terminal and made it render the other way. It didn't take long, and should...

              This was a long time ago, we were bored in the office (remember those?), and just downloaded the source of a simple terminal and made it render the other way. It didn't take long, and should basically not have been much more than reversing a for loop somewhere. IIRC it got really funny with ncurses :) Also completely forgot about if afterwards, so I guess it wasn't a success, don't remember.

              1 vote
  2. trim
    Link
    Generally speaking, my terminal will be full screen with decently large font, so I can actually read it, and a lot of the time it will be running some kind of ncurses based application such as vim...

    Generally speaking, my terminal will be full screen with decently large font, so I can actually read it, and a lot of the time it will be running some kind of ncurses based application such as vim or mc. I do understand the sentiment though. Part of my first job involved operating a telex machine for ordering, with one line of input and scrolling paper output. I can still remember the stupid telex address of that machine.

    Anyway, I suppose the closest I get these days is on my corporate windows machine running VS-Code with its little terminal view open in a 6 line window at the bottom of the application.

    9 votes
  3. [5]
    tomf
    (edited )
    Link
    that's pretty neat, actually. For ZSH... edit: 1338's is better! printf "\033[$LINES;1H" old: printf '\033[%s;1H' $((LINES - 1)) another edit: zsh4humans has zstyle ':z4h:' prompt-at-bottom 'yes'...

    that's pretty neat, actually. For ZSH...

    edit: 1338's is better!

    printf "\033[$LINES;1H"
    

    old: printf '\033[%s;1H' $((LINES - 1))

    another edit: zsh4humans has zstyle ':z4h:' prompt-at-bottom 'yes' if anybody uses that.

    7 votes
    1. Narry
      (edited )
      Link Parent
      Thank you, I used zsh and was about to be awake half the night looking for this… Edit to add, I popped the following into my ~/.zshrc: alias cls="clear; printf '\033[%s;1H' $((LINES - 1))" alias...

      Thank you, I used zsh and was about to be awake half the night looking for this…

      Edit to add, I popped the following into my ~/.zshrc:

      alias cls="clear; printf '\033[%s;1H' $((LINES - 1))"
      alias clear="clear; printf '\033[%s;1H' $((LINES - 1))"
      

      cls is in there because I sometimes have a brain fart and type that instead.

      5 votes
    2. [2]
      1338
      Link Parent
      This works for me, at the top of my ~/.zshrc so there's no gap between my prompt and the commands in my rc. Having the -1 just causes it to miss a line, not sure if there's something weird about...

      This works for me, at the top of my ~/.zshrc so there's no gap between my prompt and the commands in my rc. Having the -1 just causes it to miss a line, not sure if there's something weird about my terminal.

      printf "\033[$LINES;1H"

      3 votes
      1. xk3
        Link Parent
        Ah! It's because I print a status line after the printf--(ie. cat /proc/loadavg) so that's why I need to subtract 1 but other people either don't need that or they'll want to subtract more if they...

        Ah!

        It's because I print a status line after the printf--(ie. cat /proc/loadavg) so that's why I need to subtract 1

        but other people either don't need that or they'll want to subtract more if they print more than one informational lines

        I will edit the OP to include this information

        2 votes
    3. goose
      Link Parent
      Very nice! Only issue I'm seeing is that if I resize the window, it doesn't move to the new "bottom". But not enough of a problem to stop me from using this. Thanks!

      Very nice! Only issue I'm seeing is that if I resize the window, it doesn't move to the new "bottom". But not enough of a problem to stop me from using this. Thanks!

      2 votes
  4. Akir
    Link
    Return to teletype indeed. The first thing I thought about when I read this was that it reminded me of the interface to trebuchet and other chat type programs. I actually did at one time access a...

    Return to teletype indeed. The first thing I thought about when I read this was that it reminded me of the interface to trebuchet and other chat type programs. I actually did at one time access a computer regularly with such an application due to the lack of terminal programs on public computers at the time.

    6 votes
  5. d32
    Link
    I just realized that I'm doing it the same way, by virtue of this being the default in 'screen'. Back on the 8bits, there was a "command line" at the bottom, the rest of the screen was output....

    I just realized that I'm doing it the same way, by virtue of this being the default in 'screen'. Back on the 8bits, there was a "command line" at the bottom, the rest of the screen was output.
    Whenever I'm using the "naked" terminal without a 'screen', I'm mildly confused by the rolling cursor position.

    1 vote