LoginSignup
1

More than 5 years have passed since last update.

クリップボードの履歴をdmenuで補完して貼り付け

Last updated at Posted at 2017-05-26

履歴機能を提供するソフトウェアはあるが、検索できないのとカスタマイズ性に優れていないので、下記のコマンドを作成した。

out.gif

~/bin/save-xclip-history
#!/bin/bash

save(){
    local content="$1"
    (echo "$content" | file - | grep -q text) || return
    if ! grep -q -F -x -e "$content" ~/.xclip-history; then
        echo "$content" >> ~/.xclip-history
    fi
}
while true; do
    save "$(xclip -o -selection clipboard)"
    save "$(xclip -o -selection primary)"
    sleep 1
done
~/bin/dmenu_paste
#!/bin/bash

xdotool type -- "$(cat ~/.xclip-history | tac | dmenu -b -l 15 -p '>')"

.xinitrcsave-xclip-history & と書いておけば、自動で保存される。

呼び出しは、任意のキーに割り当てる。 awesome ではこんな感じ。

~/.config/awesome/rc.lua
    awful.key({ modkey,           }, "v", function () awful.util.spawn("dmenu_paste") end),

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1