Skip to content

Commit

Permalink
limit the length of the clip previews displayed in rofi to speed up
Browse files Browse the repository at this point in the history
render time and prevent lockups on yuuuge clips
  • Loading branch information
gilbertw1 committed Apr 28, 2017
1 parent 750ea3c commit 552a3ac
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions roficlip
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ fi
# - 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"; FS="\n"; OFS=" " } { $1=$1; print $0 }' \
| sed 's/^ *//' \
| 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" | rofi -dmenu -i -lines 20 -width 80 -p 'selection: ')"
SELECTION="$(echo "$C_HIST_SHORT" | rofi -dmenu -i -lines 20 -width 80 -p 'selection: ')"

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

0 comments on commit 552a3ac

Please sign in to comment.