You are not logged in.

#1 2015-11-13 18:33:47

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Possible to Keep Echo Text on Terminal?

Hey everyone is it possible, via bash, to have an echo'd line of text display on a single terminal. but have that single line, not be scrolled upward and out of sight when the next command is run? So basically you're creating a permanent "header" on the terminal. Any other commands with a lot of output like tcpdump, or htop, will be under "underneath" the echo'd text?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#2 2015-11-13 18:56:08

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,702

Re: Possible to Keep Echo Text on Terminal?

a. One could change the title
http://stackoverflow.com/questions/5343 … -in-ubuntu

example

#!/bin/bash

set_title() { printf "\e]2;$*\a"; }

set_title "1"
sleep 1
set_title "2"
sleep 1
set_title "3"

b. or perhaps echo things to /tmp/file and have another window open to reload that /tmp/file

Last edited by brontosaurusrex (2015-11-13 21:04:27)

Offline

#3 2015-11-13 19:39:17

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Possible to Keep Echo Text on Terminal?

Hmm not sure if the set_title would work. I'm running this terminator emulator without a window around it. It has to be "in the terminal"


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#4 2015-11-13 19:59:01

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Possible to Keep Echo Text on Terminal?

You could use screen or tmux to create a separate pane in terminal window, like this:
2015_11_13_195726_465x320_scrot.jpg

Why exactly do you want to do this?
http://xyproblem.info/


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#5 2015-11-13 20:39:51

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,702

Re: Possible to Keep Echo Text on Terminal?

terminator emulator without a window around it

c. tmux perhaps

#!/bin/bash

set_title() { tmux rename-window "$1"; }

set_title "a"
sleep 1
set_title "b"
sleep 1
set_title "c"

↥ Completely untested.

expanded: a naive approach to check from where the script is run

#!/bin/bash

set_title() {     
                if [ ! -z "$TMUX" ]; then
                    tmux rename-window "$1"; 
                else
                    printf "\e]2;$*\a";
                fi
            }

set_title "a"
sleep 1
set_title "b"
sleep 1
set_title "yes baby"

↥ Completely untested and probably wrong.

d. using notify-send

#!/bin/bash

set_title() { notify-send -t 30000 "$1"; }

set_title "oh"
sleep 1
set_title "ah"
sleep 1
set_title "blah"

Last edited by brontosaurusrex (2015-11-13 21:10:48)

Offline

#6 2015-11-14 00:32:37

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Possible to Keep Echo Text on Terminal?

Head_on_a_Stick wrote:

Why exactly do you want to do this?
http://xyproblem.info/

Heh...I actually found the XY problem even more interesting than the actual solution..  big_smile  The reason is just my own preference. I'd like the look of having the header stay on screen, while I can still type commands and work. Thanks very much though, you too brontosaurus! I was trying to avoid downloading another termie emu. but it seems like tmux is pretty the way to go for customization?


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

#7 2015-11-14 07:34:57

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,702

Re: Possible to Keep Echo Text on Terminal?

I'd go with b. where you can use tmux for window spliting (or not) and the logging to file part will be useful all the way to scripts life-cycle (for example running script from cron). It's also the simplest and not tied to a specific tech solution.
(You can also write something that would combine b. and c. < that should cover a lot of script usage cases)

Last edited by brontosaurusrex (2015-11-14 07:51:45)

Offline

#8 2015-11-14 08:45:49

ohnonot
...again
Registered: 2015-09-29
Posts: 3,484
Website

Re: Possible to Keep Echo Text on Terminal?

tmux & screen are not terminal emulators.

they would be able to do what you want, i guess.

you can also achieve a lot with the (bash) prompt, click & read some of the links here, people have been doing crazy stuff with it:
https://wiki.archlinux.org/index.php/Co … t#See_also

Offline

#9 2015-11-14 10:49:26

Snap
Member
Registered: 2015-10-02
Posts: 465

Re: Possible to Keep Echo Text on Terminal?

You could use screen or tmux to create a separate pane in terminal window

Inside terminator? You might get lost there! LOL.

My 2cents. tmux is amazing. Perhaps not that much or not that evident if running the X, but a true killer tool if running the tty. It takes the tty to a full new level.

Offline

#10 2015-11-14 10:54:59

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: Possible to Keep Echo Text on Terminal?

Snap wrote:

Inside terminator? You might get lost there! LOL.

I didn't think of that...

I always use rxvt-unicode big_smile


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#11 2015-11-14 11:43:51

ohnonot
...again
Registered: 2015-09-29
Posts: 3,484
Website

Re: Possible to Keep Echo Text on Terminal?

Snap wrote:

Inside terminator? You might get lost there! LOL.

you mean like that movie where they dive deeper and deeper into a dream within a dream within a dream...
i keep forgetting the name...

Offline

#12 2015-11-14 15:43:44

PackRat
jgmenu user Numero Uno
Registered: 2015-10-02
Posts: 921

Re: Possible to Keep Echo Text on Terminal?

^ you thinking of Inception?

@Horizon_Brave - are you looking to set a static header, or are you wanting it to change as you work for whatever reasons?

If it is a static header, then it is easy to place it in the tmux status bar (where the clock is in HOAS' screenshot of tmux).

header_in_tmux.jpg

I've never used tmux with terminator (or terminator much at all, does it have a status bar like a tmux session?), but tmux should run in terminator.

Last edited by PackRat (2015-11-14 19:26:50)


You must unlearn what you have learned.
    -- yoda

Offline

#13 2015-11-14 17:40:32

brontosaurusrex
Middle Office
Registered: 2015-09-29
Posts: 1,702

Re: Possible to Keep Echo Text on Terminal?

About the xy problem, quoting

User doesn't know how to do X, but thinks they can fumble their way to a solution if they can just manage to do Y.

I don't really find that particularity interesting or funny, I would call that the default human behavior and the solution (when found) will:

- prevent future me to behave in the same way, so in itself is a (long-term) solution.
- doing Y did a lot of important discoveries (where X was declared uninteresting at the end)
- doing Y will/may raise common know-how
- doing Y will prevent dogmatic (single book) behaviors
- the direct solution to X (generally accepted dogma) may be so stupid, that it actually needs a better way with Y in between
- I could find a lot more here

Conclusion: xy problem does need a rewrite, since it misses the actual problem, heh tongue

Last edited by brontosaurusrex (2015-11-14 18:12:01)

Offline

#14 2015-11-14 20:52:52

Horizon_Brave
Operating System: Linux-Nettrix
Registered: 2015-10-18
Posts: 1,473

Re: Possible to Keep Echo Text on Terminal?

PackRat wrote:

^ you thinking of Inception?

lol...I was thinking the same thing...

PackRat wrote:

@Horizon_Brave - are you looking to set a static header, or are you wanting it to change as you work for whatever reasons?

If it is a static header, then it is easy to place it in the tmux status bar (where the clock is in HOAS' screenshot of tmux).

http://s28.postimg.org/vn6h5f66h/header_in_tmux.jpg

I've never used tmux with terminator (or terminator much at all, does it have a status bar like a tmux session?), but tmux should run in terminator.


Yep, I'll definitely do this with tmux. And no, terminator doesn't have a status bar, atleast not that I've seen so far...Though actually I use Guake Terminal emulator the most. Thanks everyone!


"I have not failed, I have found 10,000 ways that will not work" -Edison

Offline

Board footer

Powered by FluxBB