Skip to content

Commit

Permalink
Add colorizing functionality to specified column
Browse files Browse the repository at this point in the history
  • Loading branch information
palladius committed Jul 22, 2024
1 parent ce70d0b commit 2990f89
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions bin/colorize_column
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/bash

# echo this was written with Gemini
# BUG: This doesnt preserve spaces.. but its good enough for today.

# Check if the column number is provided
if [ -z "$1" ]; then
echo "Usage: $0 <column_number>"
exit 1
fi

column_number="$1"

# Read input line by line
while IFS= read -r line; do
#while read -r line; do
# Split the line into words
words=($line)

# Check if the column number is valid
if [ "$column_number" -gt "${#words[@]}" ] || [ "$column_number" -lt 1 ]; then
echo "Invalid column number: $column_number"
continue
fi

# Colorize the specified column
# printf "AA%s " "${words[@]:0:$column_number - 1}" # Print words before the column
# printf "BB\033[1;31m%s\033[0m " "${words[$column_number - 1]}" # Print and colorize the column
# printf "CC%s\n" "${words[@]:$column_number}" # Print words after the column

echo -n "${words[@]:0:$column_number - 1}" # Print words before the column
echo -en " \033[1;33m${words[$column_number - 1]}\033[0m " # Print and colorize the column
echo "${words[@]:$column_number}" # Print words after the column


done

0 comments on commit 2990f89

Please sign in to comment.