Last active
March 17, 2022 05:35
-
-
Save morbeo/800fbe1812bdd606232b9ffa321a7166 to your computer and use it in GitHub Desktop.
list GNU screen sessions and show preview for the session
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
header_info='CTRL+D or ESCAPE to exit, ENTER attaches to a Detached screen' | |
export FZF_DEFAULT_OPTS="--header '${header_info}' --preview 'screen_peek {1}' --preview-window top,80%,follow" | |
function screen_peek() | |
{ | |
local screen=$1 | |
local pipe="$(mktemp -u)" | |
mkfifo "${pipe}" | |
screen -S "${screen}" -X hardcopy "${pipe}" | |
cat "${pipe}" | sed -e '/./,$!d' -e :a -e '/^\n*$/{$d;N;};/\n$/ba' | |
rm -f "${pipe}" | |
} | |
export -f screen_peek | |
screen_id=$(screen -ls | column -t | grep tached | fzf | awk '{print $1}') | |
if [[ "${screen_id}" ]] ; then screen -x "${screen_id}"; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment