Archive

Posts Tagged ‘terminal’

use tmux as a “GUI” interface

November 16, 2019 Leave a comment

Problem
I have a console application that clears the screen, draws a table and updates it every second in an infinite loop (let’s call it Part A). If this application is started with a specific command-line parameter, then it starts in interactive mode (Part B). From Part B I can give some commands that control Part A. How could I display both Part A and Part B in the terminal?

Solution
You can do it with tmux. With tmuxp, it’s even simpler. Here is a config file called sample.yaml that you can load with “tmuxp load sample.yaml“.

session_name: main-pane-height
windows:
- layout: main-horizontal
  options:
    main-pane-height: 35
  panes:
  - shell_command:
    - echo top pane
  - shell_command:
    - echo bottom pane
  window_name: Title Comes Here

This creates two panes and executes the specified commands in the panes. With this I could start Part A in the top pane, and Part B in the bottom pane.

Categories: bash Tags: , , , , ,

number of lines and columns of your terminal

November 16, 2018 Leave a comment
$ tput lines
22
$ tput cols
165

Of course, the values depend on your own settings.

I found it in the script snowjob.sh, which adds snowflakes to your terminal. Really cool.

Related animated short film: Operation White Widow (2011).

Update
In Nim, there are functions for these in the module terminal. See terminalWidth and terminalHeight.

reddit from the terminal

September 7, 2015 Leave a comment

There is a command line interface for Reddit called “rtv” (reddit terminal viewer). It’s written in Python, so you can install it with pip.

Here is a short youtube video on how to use it.

Categories: bash, linux, python Tags: , ,

open a terminal in a specified folder

Problem
From a script I want to launch a terminal that opens in a specified folder.

Solution
Thanks to #linux, I got two solutions:

A1) I use konsole, which has an option for this:

konsole --workdir /tmp

It will open a terminal in the /tmp directory.

A2) Change directory to the specified folder and launch the terminal:

cd /tmp; konsole

If you want to do it from a script, the idea remains the same.

B) If you want to execute a command automatically in the opening terminal, use this:

konsole -e mc

C) Set the title of Konsole to a specified text:

konsole -p tabtitle='NVIM server'

Find more info here.

Categories: bash, linux Tags: , ,

Hide the cursor in terminal

December 7, 2012 Leave a comment

Problem
You want to hide the cursor in terminal.

Solution
Hide:

setterm -cursor off

Bring it back:

setterm -cursor on

Found here.

Categories: bash Tags: ,

Terminator: a cross-platform terminal emulator with advanced features

April 9, 2011 Leave a comment

Terminator is a cross-platform GPL terminal emulator with advanced features.

I’ve been using konsole for years but I think I will switch to terminator.

Features:

  • Arrange terminals in a grid (see screenshot below)
  • Tabs
  • Highly configurable
  • Drag and drop re-ordering of terminals
  • Lots of keyboard shortcuts (see the keybindings section)
  • Save multiple layouts and profiles via GUI preferences editor

Screenshot:

Installation:

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

My config file:

See my config file here. Its location is $HOME/.config/terminator/config (rename it to “config“).

Links:

Update (20110511)
I was using terminator for a month but today I switched back to konsole. Terminator is not bad but I find some things annoying. I also sent two questions / feature requests to the developers and got no answers, so I don’t know if it’s still developed. Konsole is not that fancy but works just fine.

/ discussion /

Install ncurses

March 11, 2011 Leave a comment
sudo apt-get install libncurses5-dev libncursesw5-dev

If you want to compile a source code and you get the “curses.h: No such file or directory” error, then these are the packages you need to install.

Tip from here.