Created
October 19, 2022 05:40
-
-
Save Hayao0819/896cbd354bacc8840f765ce08647ca11 to your computer and use it in GitHub Desktop.
エスケープシーケンスで画面制御する関数
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 | |
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