… oops, sorry, much more easier ;)
Create a new tmCommand with: ---------------------------------------- #!/usr/bin/env bash [[ -f "${TM_SUPPORT_PATH}/lib/bash_init.sh" ]] && . "${TM_SUPPORT_PATH}/lib/bash_init.sh"
Rcmd="length($TM_SELECTED_TEXT)"
osascript <<-APPLESCRIPT tell application "R" to cmd "${Rcmd//"/"}" APPLESCRIPT ----------------------------------------
Input: Selection; format: Text Output: Discard Key Equivalent: "whatever you like"