Skip to content

Commit

Permalink
resolved issue where it was possible for an incorrect clip to be copied;
Browse files Browse the repository at this point in the history
minor refactors
  • Loading branch information
gilbertw1 committed Apr 29, 2017
1 parent 552a3ac commit 85313f9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions roficlip
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,20 @@ fi

# Extract clipboard history from clipster and format for rofi
# - Remove Newlines from clips
# - Limit line length to 200 chars (for display in rofi)
# - Split into lines based on NUL byte
# - Remove Leading whitespace
# - Remove empty clipboard items
# - Delete entries > 2048 characters
# - Add line numbers to clip items
# NOTE: This is all done in a single line because bash can't store a NUL byte
C_HIST="$(clipster -c -o -n 500 -0 \
| gawk 'BEGIN {RS = "\0"; ORS = "\0"} NF > 0 { print substr($0, 1, 250) }' \
| gawk 'BEGIN {RS = "\0"; FS="\n"; OFS=" " } { $1=$1; print $0 }' \
| sed '/^$/d' \
| sed 's/^ *//' \
| gawk '{printf("%003d %s\n", NR, $0)}')"

C_HIST_SHORT=$(echo "$C_HIST" | cut -c -200)

# Echo clipboard items to Rofi and save the selection made by user
SELECTION="$(echo "$C_HIST_SHORT" | rofi -dmenu -i -lines 20 -width 80 -p 'selection: ')"
SELECTION="$(echo "$C_HIST" | rofi -dmenu -i -lines 20 -width 80 -p 'selection: ')"

# Verify user made a selection
if [ -n "$SELECTION" ]; then
Expand Down

0 comments on commit 85313f9

Please sign in to comment.