Screen: Difference between revisions

From Halfface
Jump to navigation Jump to search
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
==screen==
=Start program in screen.=
Start program in screen.
  screen -d -m
  screen -d -m
CTRL + a +
=Split=
S split
CTRL + a -> S
  ? help
=Help=
  tab move between windowss
  CTRL + a -> ?
Q only this windows
=Move between split screen=
  " show list
  CTRL + a -> tab
esc histor/copy mode
=Show window list=
  ] paste
  CTRL + a -> "
  A name window
=Copy/History mode(Search via ? and /)=
  ? / search in history mode.
  CTRL + a -> ESC
detatch screen inside screen
=Show only this window=
CTRL + a -> Q
=Paste=
  CTRL + a -> [
=Name a window=
  CTRL + a -> A
=Move or swap window position/number=
:number is literary as it stands here. (:number). 2 is where you want to move window.
CTRL + a -> :number 2
 
=detatch screen inside screen=
  CTRL + a -> a -> d
  CTRL + a -> a -> d
Rename screen session.
=Rename screen session.=
  CTRL + a -> :sessionname new-session-name
  CTRL + a -> :sessionname new-session-name
=Wrap=
CTRL + a -> r
=Wrap no=
CTRL + a -> CTRL + r
=Visual bell=
CTRL + a -> CTRL + g
=Move tab in split screen=
CTRL + a -> CTRL + i
=Close split screen=
CTRL + a -> X
=Cannot open your terminal '/dev/pts/0' - please check=
sudo su - user causes problems...
script /dev/null


=external links=
=external links=

Latest revision as of 15:36, 18 November 2020

Start program in screen.

screen -d -m

Split

CTRL + a -> S

Help

CTRL + a -> ?

Move between split screen

CTRL + a -> tab

Show window list

CTRL + a -> "

Copy/History mode(Search via ? and /)

CTRL + a -> ESC

Show only this window

CTRL + a -> Q

Paste

CTRL + a -> [

Name a window

CTRL + a -> A

Move or swap window position/number

number is literary as it stands here. (:number). 2 is where you want to move window.
CTRL + a -> :number 2

detatch screen inside screen

CTRL + a -> a -> d

Rename screen session.

CTRL + a -> :sessionname new-session-name

Wrap

CTRL + a -> r

Wrap no

CTRL + a -> CTRL + r

Visual bell

CTRL + a -> CTRL + g

Move tab in split screen

CTRL + a -> CTRL + i

Close split screen

CTRL + a -> X

Cannot open your terminal '/dev/pts/0' - please check

sudo su - user causes problems...

script /dev/null

external links

http://www.gnu.org/software/screen/manual/screen.html

functions

# Run a command in a group of windows.
screen_cluster(){
  if [ $# -lt 3 ]
  then
    echo "You wrote: ${FUNCNAME} ${@}"
    echo "${FUNCNAME} SESSIONNAME 'command' SCREENS"
    SESSIONNAMES=$(screen -ls | grep -E '[[:blank:]][0-9]{2,}' | awk '{print $1}' | sed 's/^[0-9.]*//g')
    echo "SESSIONNAME available are:"
    echo "${SESSIONNAMES}"
  else
    SESSIONNAME=${1}
    COMMAND=${2}
    shift 2
    SCREENS="${@}"
    for SCREEN in ${SCREENS}
    do
      screen -S ${SESSIONNAME} -p ${SCREEN} -X stuff "^A#
${COMMAND}
"
      if [ $? -ne 0 ]
      then
        screen_cluster
        return 1
      fi
    done
  fi
}

# Split screen in regions with wanted windows.
screen_split(){
  if [ $# -lt 2 ]
  then
    echo "Splits screen in regions and show chosen windows."
    echo "${FUNCNAME} SESSIONNAME SCREENS"
  else
    SCREENSESSION="${1}"
    shift
    WINDOWSTART="${1}"
    NUMBERSCREEN="${#}"
    shift
    WINDOWSOPEN="${@}"
    screen -S ${SCREENSESSION} -p ${WINDOWSTART} -X select ${WINDOWSTART}
    screen -S ${SCREENSESSION} -p ${WINDOWSTART} -X only
    sleep 0.2
    for WINDOWOPEN in ${WINDOWSOPEN}
    do
      sleep 0.2
      screen -S ${SCREENSESSION} -p ${WINDOWSTART} -X split
      screen -S ${SCREENSESSION} -p ${WINDOWSTART} -X focus
      screen -S ${SCREENSESSION} -p ${WINDOWOPEN} -X select ${WINDOWOPEN}
    done
    screen -S ${SCREENSESSION} -p ${WINDOWSTART} -X wall "Opened ${NUMBERSCREEN} screen windows"
  fi
}