mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Refactor Alacritty scripts
This includes some changes to the scripts `README.md` to provide some more information on the different Alacritty scripts. A new script for testing the 24 bit support of Alacritty has been added with the `24-bit-color.sh` name. This should help with troubleshooting truecolor support issues. Since `perf` is a standard tool which is available in the official repositories for most distributions, it doesn't make much sense to provide an installation script specifically for Ubuntu. As a result of this, the script has been removed.
This commit is contained in:
parent
6b61e96739
commit
f32facfbfd
5 changed files with 156 additions and 30 deletions
101
scripts/24-bit-color.sh
Executable file
101
scripts/24-bit-color.sh
Executable file
|
@ -0,0 +1,101 @@
|
|||
#!/bin/bash
|
||||
# This file was originally taken from iterm2 https://github.com/gnachman/iTerm2/blob/master/tests/24-bit-color.sh
|
||||
#
|
||||
# This file echoes a bunch of 24-bit color codes
|
||||
# to the terminal to demonstrate its functionality.
|
||||
# The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
|
||||
# The background escape sequence is ^[48;2;<r>;<g>;<b>m
|
||||
# <r> <g> <b> range from 0 to 255 inclusive.
|
||||
# The escape sequence ^[0m returns output to default
|
||||
|
||||
setBackgroundColor()
|
||||
{
|
||||
#printf '\x1bPtmux;\x1b\x1b[48;2;%s;%s;%sm' $1 $2 $3
|
||||
printf '\x1b[48;2;%s;%s;%sm' $1 $2 $3
|
||||
}
|
||||
|
||||
resetOutput()
|
||||
{
|
||||
echo -en "\x1b[0m\n"
|
||||
}
|
||||
|
||||
# Gives a color $1/255 % along HSV
|
||||
# Who knows what happens when $1 is outside 0-255
|
||||
# Echoes "$red $green $blue" where
|
||||
# $red $green and $blue are integers
|
||||
# ranging between 0 and 255 inclusive
|
||||
rainbowColor()
|
||||
{
|
||||
let h=$1/43
|
||||
let f=$1-43*$h
|
||||
let t=$f*255/43
|
||||
let q=255-t
|
||||
|
||||
if [ $h -eq 0 ]
|
||||
then
|
||||
echo "255 $t 0"
|
||||
elif [ $h -eq 1 ]
|
||||
then
|
||||
echo "$q 255 0"
|
||||
elif [ $h -eq 2 ]
|
||||
then
|
||||
echo "0 255 $t"
|
||||
elif [ $h -eq 3 ]
|
||||
then
|
||||
echo "0 $q 255"
|
||||
elif [ $h -eq 4 ]
|
||||
then
|
||||
echo "$t 0 255"
|
||||
elif [ $h -eq 5 ]
|
||||
then
|
||||
echo "255 0 $q"
|
||||
else
|
||||
# execution should never reach here
|
||||
echo "0 0 0"
|
||||
fi
|
||||
}
|
||||
|
||||
for i in `seq 0 127`; do
|
||||
setBackgroundColor $i 0 0
|
||||
echo -en " "
|
||||
done
|
||||
resetOutput
|
||||
for i in `seq 255 -1 128`; do
|
||||
setBackgroundColor $i 0 0
|
||||
echo -en " "
|
||||
done
|
||||
resetOutput
|
||||
|
||||
for i in `seq 0 127`; do
|
||||
setBackgroundColor 0 $i 0
|
||||
echo -n " "
|
||||
done
|
||||
resetOutput
|
||||
for i in `seq 255 -1 128`; do
|
||||
setBackgroundColor 0 $i 0
|
||||
echo -n " "
|
||||
done
|
||||
resetOutput
|
||||
|
||||
for i in `seq 0 127`; do
|
||||
setBackgroundColor 0 0 $i
|
||||
echo -n " "
|
||||
done
|
||||
resetOutput
|
||||
for i in `seq 255 -1 128`; do
|
||||
setBackgroundColor 0 0 $i
|
||||
echo -n " "
|
||||
done
|
||||
resetOutput
|
||||
|
||||
for i in `seq 0 127`; do
|
||||
setBackgroundColor `rainbowColor $i`
|
||||
echo -n " "
|
||||
done
|
||||
resetOutput
|
||||
for i in `seq 255 -1 128`; do
|
||||
setBackgroundColor `rainbowColor $i`
|
||||
echo -n " "
|
||||
done
|
||||
resetOutput
|
||||
|
|
@ -1,20 +1,26 @@
|
|||
scripts
|
||||
Scripts
|
||||
=======
|
||||
|
||||
There are two scripts included at the time this README was written, and they
|
||||
both support flamegraph generation on Ubuntu. The first script installs the
|
||||
required dependencies:
|
||||
## Flamegraph
|
||||
|
||||
Run the release version of Alacritty while recording call stacks. After the
|
||||
Alacritty process exits, a flamegraph will be generated and it's URI printed
|
||||
as the only output to STDOUT.
|
||||
|
||||
```sh
|
||||
scripts/ubuntu-install-perf.sh
|
||||
./create-flamegraph.sh
|
||||
```
|
||||
|
||||
The second script will run Alacritty while recording call stacks. After the
|
||||
Alacritty process exits, a flamegraph will be generated and its URI printed.
|
||||
Running this script depends on an installation of `perf`.
|
||||
|
||||
## ANSI Color Tests
|
||||
|
||||
We include a few scripts for testing the color of text inside a terminal. The
|
||||
first shows various foreground and background varients. The second enumerates
|
||||
all the colors of a standard terminal. The third enumerates the 24-bit colors.
|
||||
|
||||
```sh
|
||||
scripts/create-flamegraph.sh
|
||||
./fg-bg.sh
|
||||
./colors.sh
|
||||
./24-bit-colors.sh
|
||||
```
|
||||
|
||||
**NOTE**: The _create-flamegraph.sh_ script is intended to be run from the
|
||||
alacritty project root.
|
||||
|
|
11
scripts/colors.sh
Executable file
11
scripts/colors.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
for x in {0..8}; do
|
||||
for i in {30..37}; do
|
||||
for a in {40..47}; do
|
||||
echo -ne "\e[$x;$i;$a""m\\\e[$x;$i;$a""m\e[0;37;40m "
|
||||
done
|
||||
echo
|
||||
done
|
||||
done
|
||||
echo ""
|
|
@ -1,19 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Make sure FlameGraph scripts are available
|
||||
if [ ! -e ./FlameGraph ]
|
||||
# The full path to the script directory, regardless of pwd.
|
||||
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
|
||||
# Current UNIX time.
|
||||
TIME=$(date +%s)
|
||||
|
||||
# Make sure FlameGraph scripts are available.
|
||||
if [ ! -e $DIR/FlameGraph ]
|
||||
then
|
||||
git clone https://github.com/BrendanGregg/FlameGraph
|
||||
git clone https://github.com/BrendanGregg/FlameGraph \
|
||||
$DIR/create-flamegraph/FlameGraph
|
||||
fi
|
||||
|
||||
if [ ! -e target/release/alacritty ]
|
||||
# Make sure a release build of Alacritty is available.
|
||||
if [ ! -e $DIR/../target/release/alacritty ]
|
||||
then
|
||||
echo "Must build alacritty first: cargo build --release"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# This will block while alacritty runs
|
||||
perf record -g -F 99 target/release/alacritty
|
||||
perf script | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl --width 1920 > alacritty.svg
|
||||
# Make sure perf is available.
|
||||
if [ ! -x "$(command -v perf)" ]
|
||||
then
|
||||
echo "Cannot find perf, please make sure it's installed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Flame graph created at file://$(pwd)/alacritty.svg"
|
||||
# Run perf, this will block while alacritty runs.
|
||||
perf record -g -F 99 $DIR/../target/release/alacritty
|
||||
perf script \
|
||||
| $DIR/create-flamegraph/FlameGraph/stackcollapse-perf.pl \
|
||||
| $DIR/create-flamegraph/FlameGraph/flamegraph.pl --width 1920 \
|
||||
> flame-$TIME.svg
|
||||
|
||||
# Tell users where the file is.
|
||||
echo "Flame graph created at: file://$(pwd)/flame-$TIME.svg"
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -v
|
||||
|
||||
# Get kernel info
|
||||
UNAME=$(uname -r)
|
||||
|
||||
# Install linux tools for the perf binary
|
||||
sudo apt-get install -y \
|
||||
linux-tools-common \
|
||||
linux-tools-generic \
|
||||
linux-tools-$UNAME
|
Loading…
Reference in a new issue