Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8089793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:31:02+00:00 2026-06-05T19:31:02+00:00

The alternate screen is used by many user-interactive terminal applications like vim, htop, screen,

  • 0

The alternate screen is used by many “user-interactive” terminal applications like vim, htop, screen, alsamixer, less, … It is like a different buffer of the terminal content, which disappears when the application exits, so the whole terminal gets restored and it looks like the application hasn’t output anything.

I’d like to achieve exactly the same thing in my own shell (bash) script, except that it doesn’t have to be that portable. I’d stick to linux only and xterm-based terminal emulators; but the solution should use something like tput if it’s possible. However, I don’t want to use some external scripting language (or even something like C).

Although I don’t want to use C (as it should be a bash-script with as few dependencies as possible), I had a look into the source code of less. It seems to use terminfo as the database and looks up the “ti” terminal capability in its initialisation. When removing the line, it doesn’t use the alternate sceen, so I assumed that I found the responsible code line.

However, I can’t find such a capability in man terminfo. But maybe I’m on the wrong path finding a solution for this. Maybe terminfo / tput isn’t my friend.

So (how) can I use the alternate screen in a bash script? Does somebody know a simple application in which source code I may find a hint? (C application or bash script or whatever…)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T19:31:03+00:00Added an answer on June 5, 2026 at 7:31 pm

    You can switch to the alternate screen using this command:

    $ tput smcup
    

    And back with:

    $ tput rmcup
    

    These commands just output the appropriate escape sequences for your terminal. If it is an XTERM they will be equivalent to the (more known but less elegant or portable):

    $ echo -e "\e[?1049h"
    

    And:

    $ echo -e "\e[?1049l"
    

    For more terminal control commands see man 5 terminfo.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i would to have alternate 2 colors of rows, like the first black, the
i hear that NTFS alternate data streams can be used to hide running executabes.
As a programmer used to developing native applications, I'm expanding my horizons and developing
I would like to have alternate behavior during a print stylesheet on a web
I used Rack::Bug more than one year ago, now I'd like to use it
I need to get the user's location even if the phone goes to sleep/screen
I'm developing an alternate backend for the canvas interface. I started setting up test
Anybody has an alternate way of finding and copying files in bash than: find
I want to alternate rowcolor in a GridView, using pure CSS, ie: I don't
Is there any alternate way to create stored procedure without putting all query in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.