You are not logged in.

#1 2013-06-22 15:04:42

Gulver
Member
Registered: 2013-05-24
Posts: 208

Terminal that can work reverse

Stupid question may be.

Is there any terminal emulator is or that can be configured to work upwards?

I would make love to a terminal that starts as normal but remains the input in the same place and kicking the old logs downward.

Last edited by Gulver (2013-06-22 15:06:01)

Offline

#2 2013-06-22 15:27:40

opt1mus
Member
From: UK
Registered: 2011-12-31
Posts: 212
Website

Re: Terminal that can work reverse

Offline

#3 2013-06-22 21:55:52

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Terminal that can work reverse

It has been asked on these forums previously too: https://bbs.archlinux.org/viewtopic.php … 65#p903365

Some of the responses on serverfault don't make much sense: yes it would be silly to cat a file backwards, but you could cat it normally, then just "scroll" the output down far enough so there is space for a new prompt above it.

The other response about modifying the bash source code is ridiculous for two reasons: this isn't handled by the shell: the shell just reads input and write's output - it knows nothing of terminals.  If anything one could revise the code of a virtual terminal.

But simply putting the prompt above the last text isn't that helpful.  That much is easy:

 PS1="\[\033[1;1H\]> \[\033[K\]"

The tricky part is that when a second command is then run, it just dumps its output over the previous commands output rather than scrolling it down.

One could, on the other hand, have two windows (even joined seemlessly to look like one) and commands were entered in one, and formatted output was placed in the other.

Or ... this is the 5 minute version which is pretty limited - but it is a bit of proof-of-concept prototype

#!/bin/bash
LINES=32
rm -f /tmp/sh{1,2}
clear
while read -p "> " line; do
	printf "\n> %s\n" "$line" > /tmp/sh1
	$line >> /tmp/sh1 2>&1
	cat /tmp/sh2 >> /tmp/sh1
	mv /tmp/sh1 /tmp/sh2
	clear
	echo
	head -$LINES /tmp/sh2
	tput cup 0 0
done
clear

Last edited by Trilby (2013-06-22 22:11:17)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#4 2013-06-22 23:36:15

Gulver
Member
Registered: 2013-05-24
Posts: 208

Re: Terminal that can work reverse

Your idea seems great, and fairly easy as far as I catched it, since there are no simple works that has been done.

I'd use a terminal emulator on background which, if I understood you right, can be parted as two terms.

Here is my nooby desktop:
2r2xaud.png

But the thing is that, forget about cultivate, I have no idea how to use that script as it is roll

Also, as far as I could have search this can be only accessible solution so far smile

Last edited by Gulver (2013-06-22 23:38:37)

Offline

#5 2013-06-22 23:40:10

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,545
Website

Re: Terminal that can work reverse

The two terms themselves wouldn't do it.  You'd need to set up some piping or redirection.  What made me think of that was using ScreenShell with vim where I could edit commands in one terminal window and have their output pass through a lexer and be displayed on the other (I used to do this for R scripts, the code for it is on my github).

But what I posted in that shell script is probably a much better approach.  If I get around to it I might code it properly, but it mostly works as it is.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2013-06-23 00:24:48

Gulver
Member
Registered: 2013-05-24
Posts: 208

Re: Terminal that can work reverse

Trilby wrote:

The two terms themselves wouldn't do it.  You'd need to set up some piping or redirection.  What made me think of that was using ScreenShell with vim where I could edit commands in one terminal window and have their output pass through a lexer and be displayed on the other (I used to do this for R scripts, the code for it is on my github).

But what I posted in that shell script is probably a much better approach.  If I get around to it I might code it properly, but it mostly works as it is.

Since no code-friendly linuxer took time for it, I'm guessing it is meaningless, yet might be of use for some. I would scratch around that scripts, thanks!

Offline

#7 2014-03-29 22:04:14

Blµb
Member
Registered: 2008-02-10
Posts: 224

Re: Terminal that can work reverse

What should `echo -e 'foo\nbar'` result in then? Or `cat /some/file`? The idea works for command histories, but not well for command _output_.
In the simple "reverse-everything" case you could just run a wrapper around your shell. If however you don't want "cat" etc to print files in reverse you'd need to modify the shell.

EDIT: Oh damn. This was supposed to end up in the newer https://bbs.archlinux.org/viewtopic.php?id=179261 sad
I should get some sleep sad

Last edited by Blµb (2014-03-29 22:05:36)


You know you're paranoid when you start thinking random letters while typing a password.
A good post about vim
Python has no multithreading.

Offline

#8 2014-04-11 20:23:30

vaskoiii
Member
Registered: 2014-04-11
Posts: 1

Re: Terminal that can work reverse

Can't the terminal just ALWAYS output a:
Reverse Line Feed (\e[M)
Instead of a:
Normal Line Feed (\n)

Then commands could just be used accordingly. ie)
ls -la | tac
Instead of:
ls -la | cat

However, it looks like gnome-terminal doesn't really support the Reverse Line Feed. My examples are below:

== Actual ==
Line Feed
$ echo -n -e '1\n2\n3\n'
1
2
3
$
Reverse Line Feed
$ echo -n -e '\e[M\e[M1\e[M2\e[M3\e[M'
    $

== Expected ==
Line Feed
$ echo -n -e '1\n2\n3\n'
1
2
3
$
Reverse Line Feed
$
3
2
1
$ echo -n -e '\e[M\e[M1\e[M2\e[M3\e[M'

== More Info ==
Testing was done with:
/bin/bash
In:
gnome-terminal 3.61

Offline

Board footer

Powered by FluxBB