Send OSC escape sequences
This commit is contained in:
parent
9465227fe7
commit
66c1da49fb
18
osc
Executable file
18
osc
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env ksh
|
||||||
|
(( $# < 1 )) && exit 64
|
||||||
|
[[ -v X_OSC_DISABLE || ! -t 1 ]] && exit 0
|
||||||
|
case $1 in
|
||||||
|
link)
|
||||||
|
[[ -z $2 ]] && exit 64
|
||||||
|
printf "\e]8;%s\e\\" "$2"
|
||||||
|
;;
|
||||||
|
pwd)
|
||||||
|
(( $# != 1 )) && exit 64
|
||||||
|
printf "\e]7;file://%s%s\e\\" "$HOSTNAME" "$PWD"
|
||||||
|
;;
|
||||||
|
title)
|
||||||
|
(( $# == 1 )) && exit 64
|
||||||
|
shift;
|
||||||
|
printf '\e]2;%s\e\\' "$*"
|
||||||
|
;;
|
||||||
|
esac
|
43
osc.1
Normal file
43
osc.1
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
.Dd Jun 11, 2024
|
||||||
|
.Dt TS 1
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm osc
|
||||||
|
.Nd Print OSC escape sequences
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Cm pwd
|
||||||
|
.Nm
|
||||||
|
.Cm link
|
||||||
|
.Ar URI
|
||||||
|
.Nm
|
||||||
|
.Cm title
|
||||||
|
.Ar word ...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
.Nm
|
||||||
|
prints an OSC escape sequence to stdout if connected to a tty.
|
||||||
|
If stdout is not a TTY, prints nothing.
|
||||||
|
.Pp
|
||||||
|
Three escape sequences are supported:
|
||||||
|
.Bl -tag
|
||||||
|
.It pwd
|
||||||
|
ESC 7, set current working directory.
|
||||||
|
.It link
|
||||||
|
ESC 8, display an URI.
|
||||||
|
.It title
|
||||||
|
ESC 2, set a title for the current window.
|
||||||
|
.El
|
||||||
|
.Pp
|
||||||
|
Whatever it is done with these escape sequences depends on the
|
||||||
|
terminal emulator. To avoid printing anything, even on ttys, define
|
||||||
|
.Ev X_OSC_DISABLE
|
||||||
|
with any value.
|
||||||
|
.Sh ENVIRONMENT
|
||||||
|
.Bl -tag -width X_OSC_DISABLE
|
||||||
|
.It Ev X_OSC_DISABLE
|
||||||
|
Don't do anything.
|
||||||
|
.El
|
||||||
|
.Sh EXIT STATUS
|
||||||
|
.Ex -std
|
||||||
|
.Sh AUTHORS
|
||||||
|
.An Adolfo Perez Alvarez Aq Mt adolfopa@sdf.org
|
Loading…
x
Reference in New Issue
Block a user