-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add colorizing functionality to specified column
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
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
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 | ||
|