Skip to content

Instantly share code, notes, and snippets.

@tarik02
Created August 6, 2019 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tarik02/1d2fa917b7d1aff511c53ba76c8577fa to your computer and use it in GitHub Desktop.
Save tarik02/1d2fa917b7d1aff511c53ba76c8577fa to your computer and use it in GitHub Desktop.
wsl polyfills
#!/bin/bash
if (( $# > 0 )); then
lovec.exe "$@"
else
lovec.exe .
fi
#!/bin/bash
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-out)
OUT=YES
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
if [[ $OUT == YES ]]; then
paste.exe | sed -e 's/\r//g'
else
cat | sed -e 's/\n/\r\n/g' | clip.exe
fi
#!/bin/bash
TEMP=`getopt -o afiocdpsbkxd:t:l:nhv --long append,follow,input,output,clear,delete,primary,secondary,clipboard,keep,exchange,display:,selectionTimeout:,logfile:,nodetach,help,verbose,version \
-n 'xsel' -- "$@"`
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
eval set -- "$TEMP"
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-i|--input)
INPUT=YES
shift
;;
-a|--append)
APPEND=YES
shift
;;
-f|--follow)
FOLLOW=YES
shift
;;
-o|--output)
OUTPUT=YES
shift
;;
-c|--clear)
CLEAR=YES
shift
;;
-d|--delete)
DELETE=YES
shift
;;
-x|--exchange)
EXCHANGE=YES
shift
;;
-p|--primary)
PRIMARY=YES
shift
;;
-s|--secondary)
SECONDARY=YES
shift
;;
-b|--clipboard)
CLIPBOARD=YES
shift
;;
-k|--keep)
KEEP=YES
shift
;;
-x|--exchange)
EXCHANGE=YES
shift
;;
-d|--display)
shift 2
;;
-t|--selectionTimeout)
shift 2
;;
-l|--logfile)
shift 2
;;
-n|--nodetach)
shift
;;
-h|--help)
shift
;;
-v|--verbose)
shift
;;
--version)
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}"
if [[ $CLEAR == YES ]]; then
echo | clip.exe
fi
if [[ $INPUT == YES ]]; then
if [[ $APPEND == YES || $FOLLOW == YES ]]; then
(paste.exe; cat | sed -e 's/\n/\r\n/g') | clip.exe
else
cat | sed -e 's/\n/\r\n/g' | clip.exe
fi
elif [[ $OUTPUT == YES ]]; then
paste.exe | sed -e 's/\r//g'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment