Skip to content

Instantly share code, notes, and snippets.

@Hayao0819
Created October 19, 2022 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hayao0819/896cbd354bacc8840f765ce08647ca11 to your computer and use it in GitHub Desktop.
Save Hayao0819/896cbd354bacc8840f765ce08647ca11 to your computer and use it in GitHub Desktop.
エスケープシーケンスで画面制御する関数
#!/usr/bin/env bash
ClearScreen() { printf "\033[2J" ; }
ClearRight() { printf "\033[0K" ; }
ClearLeft() { printf "\033[1K" ; }
ClearLine() { printf "\033[2K" ; }
MoveCursor() { printf "\033[%d;%dH" "$1" "$2" ; }
MoveCursorUp() { printf "\033[%dA" "$1" ; }
MoveCursorDown() { printf "\033[%dB" "$1" ; }
MoveCursorRight() { printf "\033[%dC" "$1" ; }
MoveCursorLeft() { printf "\033[%dD" "$1" ; }
ResetStyle(){
printf "\033[0m"
}
ClearUpperLines(){
# shellcheck disable=SC2034
for i in $(seq 1 "$1"); do
MoveCursorUp 1
ClearLine
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment