dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE

copy-selection-to-clipboard (647B)


      1 #!/usr/bin/env sh
      2 
      3 # Description: Copy paths of selection to clipboard
      4 #
      5 # Shell: generic
      6 # Author: Arun Prakash Jana
      7 
      8 # Linux
      9 f="$(xargs -0 < ~/.nnncp)"
     10 #extension=$(echo "${f##*.}" | awk '{print tolower($0)')
     11 mimetype=$(file --mime-type -Lb "$f")
     12 
     13 case "$mimetype" in
     14     image/*)
     15         xclip -selection clipboard -t "$mimetype" < "$f"
     16         ;;
     17     *) 
     18         # otherwise copy path to clipboard
     19         echo "$f" | xclip -i -selection clipboard
     20         ;;
     21 esac
     22 
     23 
     24 
     25 # macOS
     26 # cat ~/.nnncp | xargs -0 | pbcopy
     27 
     28 # Termux
     29 # cat /data/data/com.termux/files/home/.nnncp | xargs -0 | termux-clipboard-set
     30 
     31 # Cygwin
     32 # cat ~/.nnncp | xargs -0 | clip