Guest User

Untitled

a guest
Aug 24th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.08 KB | None | 0 0
  1. # source this file to put bash's input line at the top of the screen
  2. # you'll probably also want to set horizontal-scroll-mode in .inputrc so
  3. # if you type a long command, it won't spill over into your scrollback
  4.  
  5. base_PS1='[\u@\h \W]\$ '
  6. # \e[H moves to top left, \e[K erases to end of line
  7. PS1="\[\e[H\e[K\]$base_PS1"
  8.  
  9. pre_command () {
  10.     # enable scrolling from line 2 to bottom of screen
  11.     printf "\e[2;${LINES}r"
  12.     # move cursor to bottom of screen, column 1
  13.     printf "\e[${LINES};1H"
  14.     # print command
  15.     printf "\n+ %s\n" "$BASH_COMMAND"
  16.  
  17.     # re-enable full-screen scrolling for less, which behaves slightly
  18.     # strangely otherwise. will likely need to account for other commands
  19.     # here. fixing this properly for less would probably involve writing a
  20.     # wrapper script that reset the screen before running /usr/bin/less and
  21.     # setting PAGER to it, so that indirect invocations (e.g. via man)
  22.     # would work too
  23.     if [[ $BASH_COMMAND =~ ^[[:space:]]*less([[:space:]]|$) ]]
  24.     then
  25.             printf "\e[r"
  26.     fi
  27. }
  28. trap pre_command DEBUG
  29. clear
Add Comment
Please, Sign In to add comment