현재 xterm 색상에 프로그래밍 방식으로 액세스

현재 xterm 색상에 프로그래밍 방식으로 액세스

아래 스레드에서

현재 xterm 배경색에 프로그래밍 방식으로 액세스합니까?

Alex North-Keys는 현재 xterm의 배경색을 반환하는 유용한 bash 스크립트를 제공합니다. 이 스크립트의 출력을 사용하여 배경색이 변경된 후(예: 원격 시스템에 로그인한 후) 배경색을 재설정하고 싶습니다.

예를 들어, 그의 스크립트는 다음과 같은 것을 반환할 수 있습니다.

rgb:e0e0/ffff/ffff

불행히도 배경색을 설정하는 데 사용하는 이스케이프 시퀀스

echo -ne "\033]11;!*\007"

아이보리처럼 이름이 지정된 색상을 입력한 경우에만 작동하는 것 같습니다.

e0e0/ffff/ffff와 같은 인수를 사용하도록 이 명령을 수정하는 방법이 있습니까?

감사해요!

답변1

Emacs 또는 Vim에 복사하여 붙여넣으세요. 삭제 #????? 줄 중 하나를 시작합니다. 그 줄에는 "^["를 포함하는 sed 문이 있습니다. 이것은 한 문자 ESC(^[)로 바꿔야 하는 2문자의 텍스트입니다. Vim에서는 C+v ESC를 입력하세요. Emacs에서는 C+q ESC를 입력합니다.

# filename: OSC_11_Pt_ST.sh
echo -e "\e[7m Reverse the FG/BG colors on this terminal as a visual aid. \e[0m"
y='\' # Add to end of $result (\e]11;rgb:??/??/??\e) to complete ST terminating
# OSC sequence.
# Query the background color using ST (string terminate) vice BEL (^G).Replies
# with a control sequence in RGB specification format using same terminator as
# the query (in this case, ST): "^[]11;rgb:4242/2525/5353^[\" (see file
# ctlseqs.txt). "^[" is ESC (\e); "^[]" is OSC; "^[\" is ST.
echo -en "\e]11;?\e\\"
# Read line from the standard input & assign to variable CSPEC (color specifi-
# cation as indicated by ctlseqs.txt). Do not echo input coming from terminal
# (-s); raw (-r); delimiter \ (-d).
read -s -r -d '\' CSPEC
#?????result=$(echo $CSPEC | sed 's/^[/\\\e/g')
# Set BG to "WebGrey" (decimal 128 128 128).
echo 'Set BG to "Webgrey" in 5 seconds...'
sleep 5
echo -en "\e]11;rgb:80/80/80\007"
echo "Return to original BG ($result$y) in 5 seconds..."
sleep 5
echo -en "$result$y"

관련 정보