Kludge to make less, vim et al. leave the screen uncluttered enjoy!

I have written a script which leaves the screen uncluttered when finishing less.
This script is written for bash in the "good old terminal", but works well with
iTerm too. I wrote this script because less is opposite of more as less is so
much more as more is so much less.
I hope you will use this script and reap the rewards of using less while reading
textfiles, gaining from less's features, avoiding the cluttering which may have
made you disliking using less. You can make a copy of the script and modify and wrap
the script around any other characterbased program which clutters your terminal screen.
The script works by beeing placed in your ~/bin which I assume is before
/usr/bin in your $PATH where the binary less resides. You must modify the paths
in the script if they are different from that. (both the binary less, the script,
and the kludge.scr)
The script installs an interrupthandler which are triggered by changing the
windowsize. The interupthandler figures out what it must do to preserve
your screen when you exit less, and just does so, except for four characters
to the extreme left on one line. (wich may well be part of your prompt).
The interrupthandler gets its work done, by calling a kludge which are
relatively referenced in the script from your homefolder, -presumes ~/bin
- YOU MUST EDIT THE SCRIPT OTHERWISE. The configuration is like it is because
that is what it takes to make the correct things happen in bash.
I think this could have been accomplished much easier using another shell,
but most people uses bash, especially newcomers, and they deserve to have
it as easy as possible, while reaping the productivity gains laying dormant
in the Unix core, so I hope you will share the script with you liberally,
if you think it is worth the time and the work it takes to "install" it.
I hope you will give this script a try, as to make less work comfortably for you,
I have included an environment variable with all settings I like in less, which
you may modify.
Less was the first program I had that made me think "wow" back in 1986, beeing used
to the "more" command, - which was, and is so much less than less. You can for instance
invoke BBedit with a file you are viewing in less by pressing "v" if you have BBedit
specified in the $EDITOR variable. You can pipe some text to the clipboard.
Or you can pipe some lines out of a document you are viewing in less and into
a file while viewing, you can load it with multiple files, and search them all,
a programemer can make less work with tagfiles; you can have less create a logfile
of what you read and, you can even scroll backwards. All in all less is a very handy
tool which I think everybody would gain from using,in opposite to more.
Especially when it leaves the screen uncluttered.
Great care have been taken in order to make this kludge work properly.
Still I MAKE ABSOLUTELY NO WARRANTIES ABOUT WHATSOEVER AND ANYTHING.
-USE IT AT YOUR OWN RISK.
You may do whatever you wish to do with it, aside from selling it alone, but you
are free to do whatever that you please with it, aside from distributing
malfunctioning copies or incomplete copies or tinker with the Copyright notice
in the scripts.
-------------------------------------------------- here comes the kludge for less - sends with you a tar as well. 8859 - encoded I think.
#! /bin/bash
# Less - lets us keep our screen nice even after resize, having used less or any other
# character based program - like vim, which may leave an unorderly screen.
# The fact that programs do clutter up the screen is because they probably didn't figure
# that we one day would be able to resize our terminals when they specified the standards at
# Ansi back in the 60's.
# Installing : put it together with "kludge.bash" in your $HOME/bin folder ( ~/bin ).
# its intended to work with the bash shell under MacOsX, the binary less is supposed
# to reside in /usr/bin, if it isnt; ("which less" reveals where), adjust the path.
# less - to be placed in the ~/bin folder is the wrap around less to make it behave
# Copyright 2008 Tommy Bollman Public Domain. -No WARRANTIES ABOUT WHAT SO EVER-
# Please do modify it for other programs which need helps with its cleanup as well.
# ~ is an expansion for your home directory aka /Users/John\ Doe
# Please document your version properly if you are posting it, relieving others.
export LESS=" -I -r -f -J -S -g -M -x 4"
# -I ignore case when searching
# -r "raw" do not preparate ctrl-chars,
# -f force open special files (may be binary) BEWARE OF ANSISEQUENCES.
# -J show status column
# -S chop long lines.
# -g highlight on last hit in the search.
# -M Most Verbose status column...
# -x 4 tabspacing = 4
# -------------------------------------- the screen handling starts here.................
ORIGLINES=$LINES
ESC=`printf "\e"`
ScreenRedraw_off=`echo -n "$ESC""[8m"`
ScreenRedraw_on=`echo -n "$ESC""[0m"`
function OkayScreen()
export PS1="" # Turns off the prompt to avoid cluttering..
echo -n ${ScreenRedraw_off}
CURLINES=`bash -i < ~/bin/kludge.bash `
# ^^^^^^^^^^^ NB! the path where kludge.bash should be placed.
if [ $CURLINES -gt $ORIGLINES ] ; then
TO_SKIP="$(expr "$CURLINES" '-' "$ORIGLINES")"
if [ $TO_SKIP -lt 3 ] ; then
TO_SKIP="$(expr "$TO_SKIP" '-' '2')"
else
TO_SKIP="$(expr "$TO_SKIP" '-' '1')"
fi
tput cuu 1 #cursor up one line
echo -n ${ScreenRedraw_on}
echo -n "\$####" #restores an erased '$' making only 3 chars disappear.
# ^ $ = prompt - $PS1. .(I have just a dollar here but if yours is longer,
# you can add the first four if it's static, and you'll loose nothing!!)
echo -n ${ScreenRedraw_off}
tput cud $TO_SKIP # move cursor to where it should be.
echo -n ${ScreenRedraw_on}
echo # activate the cli at correct position.
else
tput cuu 2
echo ${ScreenRedraw_on}
fi
trap OkayScreen SIGWINCH
/usr/bin/less $@
# ^^^^^^^^ NB! The path where the BINARY less is installed.
trap '' SIGWINCH
-------------------------------------------------------------------------------- and here is the kludge wich makes it all work!
#! /bin/bash
# kludge.scr - to be placed in the ~/bin folder is the inner workings of the bash script named less
# Copyright 2008 Tommy Bollman
PS1=""
shopt -s checkwinsize
echo $LINES
----><---------------------- EOF.

I have written a script which leaves the screen uncluttered when finishing less.
This script is written for bash in the "good old terminal", but works well with
iTerm too. I wrote this script because less is opposite of more as less is so
much more as more is so much less.
I hope you will use this script and reap the rewards of using less while reading
textfiles, gaining from less's features, avoiding the cluttering which may have
made you disliking using less. You can make a copy of the script and modify and wrap
the script around any other characterbased program which clutters your terminal screen.
The script works by beeing placed in your ~/bin which I assume is before
/usr/bin in your $PATH where the binary less resides. You must modify the paths
in the script if they are different from that. (both the binary less, the script,
and the kludge.scr)
The script installs an interrupthandler which are triggered by changing the
windowsize. The interupthandler figures out what it must do to preserve
your screen when you exit less, and just does so, except for four characters
to the extreme left on one line. (wich may well be part of your prompt).
The interrupthandler gets its work done, by calling a kludge which are
relatively referenced in the script from your homefolder, -presumes ~/bin
- YOU MUST EDIT THE SCRIPT OTHERWISE. The configuration is like it is because
that is what it takes to make the correct things happen in bash.
I think this could have been accomplished much easier using another shell,
but most people uses bash, especially newcomers, and they deserve to have
it as easy as possible, while reaping the productivity gains laying dormant
in the Unix core, so I hope you will share the script with you liberally,
if you think it is worth the time and the work it takes to "install" it.
I hope you will give this script a try, as to make less work comfortably for you,
I have included an environment variable with all settings I like in less, which
you may modify.
Less was the first program I had that made me think "wow" back in 1986, beeing used
to the "more" command, - which was, and is so much less than less. You can for instance
invoke BBedit with a file you are viewing in less by pressing "v" if you have BBedit
specified in the $EDITOR variable. You can pipe some text to the clipboard.
Or you can pipe some lines out of a document you are viewing in less and into
a file while viewing, you can load it with multiple files, and search them all,
a programemer can make less work with tagfiles; you can have less create a logfile
of what you read and, you can even scroll backwards. All in all less is a very handy
tool which I think everybody would gain from using,in opposite to more.
Especially when it leaves the screen uncluttered.
Great care have been taken in order to make this kludge work properly.
Still I MAKE ABSOLUTELY NO WARRANTIES ABOUT WHATSOEVER AND ANYTHING.
-USE IT AT YOUR OWN RISK.
You may do whatever you wish to do with it, aside from selling it alone, but you
are free to do whatever that you please with it, aside from distributing
malfunctioning copies or incomplete copies or tinker with the Copyright notice
in the scripts.
-------------------------------------------------- here comes the kludge for less - sends with you a tar as well. 8859 - encoded I think.
#! /bin/bash
# Less - lets us keep our screen nice even after resize, having used less or any other
# character based program - like vim, which may leave an unorderly screen.
# The fact that programs do clutter up the screen is because they probably didn't figure
# that we one day would be able to resize our terminals when they specified the standards at
# Ansi back in the 60's.
# Installing : put it together with "kludge.bash" in your $HOME/bin folder ( ~/bin ).
# its intended to work with the bash shell under MacOsX, the binary less is supposed
# to reside in /usr/bin, if it isnt; ("which less" reveals where), adjust the path.
# less - to be placed in the ~/bin folder is the wrap around less to make it behave
# Copyright 2008 Tommy Bollman Public Domain. -No WARRANTIES ABOUT WHAT SO EVER-
# Please do modify it for other programs which need helps with its cleanup as well.
# ~ is an expansion for your home directory aka /Users/John\ Doe
# Please document your version properly if you are posting it, relieving others.
export LESS=" -I -r -f -J -S -g -M -x 4"
# -I ignore case when searching
# -r "raw" do not preparate ctrl-chars,
# -f force open special files (may be binary) BEWARE OF ANSISEQUENCES.
# -J show status column
# -S chop long lines.
# -g highlight on last hit in the search.
# -M Most Verbose status column...
# -x 4 tabspacing = 4
# -------------------------------------- the screen handling starts here.................
ORIGLINES=$LINES
ESC=`printf "\e"`
ScreenRedraw_off=`echo -n "$ESC""[8m"`
ScreenRedraw_on=`echo -n "$ESC""[0m"`
function OkayScreen()
export PS1="" # Turns off the prompt to avoid cluttering..
echo -n ${ScreenRedraw_off}
CURLINES=`bash -i < ~/bin/kludge.bash `
# ^^^^^^^^^^^ NB! the path where kludge.bash should be placed.
if [ $CURLINES -gt $ORIGLINES ] ; then
TO_SKIP="$(expr "$CURLINES" '-' "$ORIGLINES")"
if [ $TO_SKIP -lt 3 ] ; then
TO_SKIP="$(expr "$TO_SKIP" '-' '2')"
else
TO_SKIP="$(expr "$TO_SKIP" '-' '1')"
fi
tput cuu 1 #cursor up one line
echo -n ${ScreenRedraw_on}
echo -n "\$####" #restores an erased '$' making only 3 chars disappear.
# ^ $ = prompt - $PS1. .(I have just a dollar here but if yours is longer,
# you can add the first four if it's static, and you'll loose nothing!!)
echo -n ${ScreenRedraw_off}
tput cud $TO_SKIP # move cursor to where it should be.
echo -n ${ScreenRedraw_on}
echo # activate the cli at correct position.
else
tput cuu 2
echo ${ScreenRedraw_on}
fi
trap OkayScreen SIGWINCH
/usr/bin/less $@
# ^^^^^^^^ NB! The path where the BINARY less is installed.
trap '' SIGWINCH
-------------------------------------------------------------------------------- and here is the kludge wich makes it all work!
#! /bin/bash
# kludge.scr - to be placed in the ~/bin folder is the inner workings of the bash script named less
# Copyright 2008 Tommy Bollman
PS1=""
shopt -s checkwinsize
echo $LINES
----><---------------------- EOF.

Similar Messages

  • How to make an object getting out of the screen ?

    Hello everybody !
    I am creating a game introduction with Flash pro CS6 and here's is my problem.
    I want a object in my animation to leave the screen, but I dont know how to do it.
    Is there for example, a way to delimited the working area, so that when I make an object go out of this area, it does not appear in my final animation ( no matter the format, .avi, .mov, spritesheets ... ) or can eventualy be "cut" ( if I make my object half inside the working arear and half outside ) ?
    Is there an other way to do this ?
    Thanks !

    Using a mask might be one way.

  • My new version of Firefox (downloaded automatically) on my Mac displays long paragraphs in emails as a single line, so the end of the paragraph is off the screen. How can I make it automatically wrap to fit the screen?

    Long paragraphs in incoming emails display as a single line, with the end of the paragraph running off the screen. I want to make it wrap automatically to fit the screen.

    For the browser window, just drag it to the top left of the screen (click and hold on the top bar with the traffic lights to drag), then in the bottom right of the window you'll see a rectangle with diagonal hatching. Click and hold on that and drag the window to the size you want.
    Clicking on the green dot at top left will expand the window to fit the screen, clicking it again will shrink it back to where it was (this doesn't work in Finder windows quite the same).
    The menu bar size is set in the bowels of the OS, though there may be third-party applications which can alter it.
    As it's size is relative to the screen resolution, you could try reducing the resolution in System Preferences > Displays to see if that would suit you better.

  • When loading video or tv shows it is taking as long as 14 hours plus - if I leave the loading screen it doesn't continue to load? So you have to wait without leaving the screen for 14 hours?

    When loading video or tv shows it is taking as long as 14 hours plus - if I leave the loading screen it doesn't continue to load? So you have to wait without leaving the screen for 14 hours? Unfortunately - I've been reading that this lengthy download problem is quite common - although I thought I saw where someone had loaded videos the day before and then had them to watch later. So, my first rental - I downloaded it overnight - then we go to watch it tonight and it proceeds to start loading again...saying it will be ready in 14 hours and 21 minutes!!! Am I doing something wrong here? If anyone has advice - I would greatly appreciate it. This is the first apple product that I am disappointed with

    When loading video or tv shows it is taking as long as 14 hours plus - if I leave the loading screen it doesn't continue to load? So you have to wait without leaving the screen for 14 hours? Unfortunately - I've been reading that this lengthy download problem is quite common - although I thought I saw where someone had loaded videos the day before and then had them to watch later. So, my first rental - I downloaded it overnight - then we go to watch it tonight and it proceeds to start loading again...saying it will be ready in 14 hours and 21 minutes!!! Am I doing something wrong here? If anyone has advice - I would greatly appreciate it. This is the first apple product that I am disappointed with

  • How can i make my phone die faster if the screen is black

    how can i make my phone die faster if the screen is black?

    There are some misconceptions that open apps consume battery power.  This is generally incorrect.  Read: http://speirs.org/blog/2012/1/2/misconceptions-about-ios-multitasking.html

  • I can't get my cursor to completely leave the screen, so when I'm watching videos on some services the video control menu stays at the bottom of the screen. How do I make it disappear so I don't have to see the progress bar and stop/start buttons?

    When I watch certain video services like amazon or Netflix and enter full screen, when I move the cursor a video menu pops up on the bottom of the screen and won't disappear until the cursor goes offscreen. But my cursor won't go fully off screen. Just the tip remains visible so the video menu doesn't leave.

    What happens if you simply click the trackpad in the movie area before the cursor disappears?  Does that cause the video menu to disappear?

  • How can I make iPhone 4S Video's fill the screen when using them in iMovie 11 on My MacBook Pro

    Hey Guys.
    I am a singer songwriter from he UK.... I recently bought an Iphone4s, Ipad and Mac book pro (haha, apple hero, I know). I have always wanted to make the big jump to apple, just was waiting a little while.
    I am thrilled so far, it's all great. But, I use Imovie (i am still getting to grips with it, but the features are amazing) to make videos of me singing coversand original videos for youtube.
    The Camera on the iphone4s is great.
    But, when I import videos into Imovie11, the videos do not fill the screen in their original form.
    In some videos, I use the Ken Burns effect. Now, on the parts of my video when I use this effect, it fills the screen as it should do.
    Why do the videos in their untampered form not do this?  I have tried importing widescreen, original size, and Large, but it alwys sits in the middle of the screen, fairly thin lookin. It fills the screen when it's on my Iphone, I am very lost.
    plesse help.
    thanks.

    if i can offer any more info please just ask

  • HT4085 The volume icon won't leave the screen and I can't seem to reset the volume. Does anyone know how to fix this?

    My iPad2 will not clear the volume icon from the screen no matter what I do. I've reset the ipad and nothing I do will make that icon go away and I can no longer control the volume. Am I missing something here, or does this warrant a trip to the Apple store?

    The volume icon on the screen means that the pad thinks you are pressing the volume rocker on the side.   Make sure that it is not being pressed by a case, or a dent, or anything else.  Make sure it rocks back and forth freely without getting stuck.
    If it moves freely, and if you have already done a full reboot, then a trip to the store may be in order. 

  • How can I make an image (gif) go over the screen with javascript?

    Hello,
    I'm working on a website for an archery club. Everything works great but I want an arrow going from one side to the other on a certain moment.
    I cannot find a script that works like I want. The image should start out of the screen and has to leave on the other side with a certain speed.
    I'm not able to write such a script myself. I'm not certain how or when it should start but I can fix that in the script I guess.
    Thanks for any help,
    Regards,
    Theo

    Use jQuery with JSTween animation plugin.
    http://www.jstween.org/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/

  • Leave the screen without process next instructions.

    Hi All,
    In my module pool program  in PAI modules I keep one information message after getting the information message the control should not go further program lines, it should stop there and selection screen should appear with input values the user will correct the input value and run the program.
    How can I forcefully exit the another modules(program lines).
    Thanks and regards,
    Krish.......

    Hi Krish,
    If i understood the problem correctly, you need to use EXIT statement.
       IF flag EQ 'X'.
          MESSAGE i087(ztest) DISPLAY LIKE 'E'.
          EXIT.
      ENDIF.
    Depending on screen sequence use it.
    If you want to skip some screens and come back to particular screen after some user action ;
    you can use SET SCREEN 0 and then LEAVE TO SCREEN 0.
    Please read F1 help for it.
    I hope this will help you.
    Regards,
    Rahul

  • How do I make my iPad turn off when the screen is covered?

    My old iPad would turn off when I closed the cover but I cannot find how to make the iPad air turnoff in a similar fashion?

    dpna wrote:
    Yes it is a proper cover
    If it is an APPLE COVER, perhaps it's not the one for that model. But, if it's not an Apple cover, then maybe the manufacturer hasn't set up the magnets the way they are supposed to be.
    I'm going to quote from another post elsewhere ...
    Are you using a genuine Apple cover or another third party cover?
    It's the magnets in the cover which activate the lock/unlock feature to appear in your settings. In earlier iPads you could slide a magnet down the side of the iPad to find where the magnet activates and turn the feature on.....Apple have now changed how this works with the iPad Air. Whereas before there was only 1 magnet positioned in the cover for earlier iPads, it is now thought there are 2 with alternating polarity.
    So if you want this feature you will need to buy an Apple cover or wait for third party manufacturers to get their magnets in the correct position.
    If you do have a genuine Apple cover then there is something going wrong here....

  • How do I make previously downloaded apps appear on the screen? Now, I have to open them in the App Store.

    I just upgraded to iOS 7. My downloaded apps no longer appear on the screen; I have to open them from wihtin the App Store. How do I get them out of there? The only option I see when I call them up in the App Store is "open."
    Thanks.

    Did you update your iOS via iTunes and the computer? If so, did you transfer purchases? Your Apps that were purchased via the App store on the phone should still be on the phone. Have you checked all of the home pages? Try a reset, hold the sleep/wake and home buttons together until you see the Apple logo and then release. After the phone reboots, see if they are back. If they are on the computer, you can also connect to iTunes and sync them back.

  • My Ipad has been asking me to backup my icloud data....for two weeks. now the reminder notification refuses to leave the screen and i can do nothing on my IPAD, including switching it off.....i hve tried to access my PC and go to icloud and back up data

    My IPAD has been asking me to bckup my info onto icloud for over 2 weeks. i was travelling and was unable to do the same. now that i am trying to back up the ipad using the ipad device.....the reminder notification on my screen is locked.......i cant get rid of it.....as long as the notification remains, i cannot even switch off the ipad or access any other screen or icon....i have now logged on to the icloud site using my pc but have been unable to locate where i may be able to sync my data remotely so that perhaps the notification on my ipad dissappears......any help? is there another way to do this?

    We need to be clear here. Did you create a second ID, or just modify the single ID?

  • I put something on my phone that makes 4 cirlces pop up on the screen an its stopping me from doin anything can some one please help?

    I need help please!!!!

    Not quite sure what you mean...
    The Basic Troubleshooting Steps are:
    Restart... Reset... Restore from Backup...  Restore as New...
    Restart / Reset
    http://support.apple.com/kb/ht1430
    Backing up, Updating and Restoring
    http://support.apple.com/kb/HT1414
    iPhone User Guide

  • Safari Widget will not leave the screen

    I have been using several widgets that I created with Safari 3. Everything was going fine until today. One of my widget appears on my screen at all time. My other widgets works perfectly but this one always stays on the screen even if I pushed the F12 key and that all my other ones have disapeared.
    Any idea how to fix this? I though of just deleting the widget and recreate it after from the web page in Safari but I don't know where the widgets created with Safari 3 are stored. Please help! I have this big square on my screen ad I can't give rid of it.

    Could be a hardware problem and would need checking out, however it could also be a software problem in that it could be an app that's causing the problem that uses the ringer volume, such as Pandora, so first backup your iPad in iTunes then delete apps particularly that uses the volume control on your iPsd and see if the ringer symbol disappears for good then reinstall any apps that you deleted.

Maybe you are looking for