Created
October 24, 2024 18:45
-
-
Save kaveet/caf539af3f6daa932ca39e0fb49a42a9 to your computer and use it in GitHub Desktop.
A Raycast Script command to covert from a column of text to a comma-separated, single-quoted list.
This file contains hidden or 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
| #!/bin/bash | |
| # Required parameters: | |
| # @raycast.schemaVersion 1 | |
| # @raycast.title Column to Comma-Separated | |
| # @raycast.description Converts a column of data into a comma-separated list with single quotes and copies it to the clipboard. | |
| # @raycast.mode compact | |
| # @raycast.packageName Conversions | |
| # Optional parameters: | |
| # @raycast.icon 🗂 | |
| # Read the clipboard contents | |
| clipboard=$(pbpaste) | |
| # Initialize an empty array to hold the quoted entries | |
| quoted_entries=() | |
| # Iterate over each line in the clipboard | |
| while IFS= read -r line; do | |
| # Skip empty lines to avoid adding empty quotes | |
| if [[ -n "$line" ]]; then | |
| quoted_entries+=("'$line'") | |
| fi | |
| done <<< "$clipboard" | |
| # Join the quoted entries with commas | |
| comma_separated=$(IFS=, ; echo "${quoted_entries[*]}") | |
| echo "$comma_separated" | pbcopy | |
| echo "✅ Contents have been copied to the clipboard." |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use:
~/Raycast/scripts/Column to Comma-Separatedfrom Raycast