[READ-ONLY] Mirror of https://github.com/probablykasper/my-bash-scripts. My personal bash scripts
cli
0

Configure Feed

Select the types of activity you want to include in your feed.

Added "copy" script

Kasper (Dec 6, 2019, 5:22 PM +0100) 53954319 53132af9

+38
+7
README.md
··· 28 28 29 29 If you've installed auto completion for `docker-compose` ([here's how to do that](https://docs.docker.com/compose/completion/)), you can enable auto completion for `d-c` by adding `complete -F _docker_compose d-c` to your `.bash-profile`. 30 30 31 + ## copy 32 + Run a command and copy the output to the clipboard. For example, run `copy pwd` to copy the current path. 33 + ``` 34 + Usage: 35 + copy <command> [args...] 36 + ``` 37 + 31 38 ## md5compare 32 39 Compares md5s of two files. 33 40 ```
+31
bin/copy
··· 1 + #! /bin/bash 2 + 3 + color() { 4 + echo -n "`tput setaf $1`${@:2}" 5 + # reset color if there are arguments: 6 + if [[ "$#" > 1 ]]; then echo -n "`tput sgr0`"; fi 7 + } 8 + red() { color 1 "$@"; } 9 + green() { color 2 "$@"; } 10 + cyan() { color 6 "$@"; } 11 + reset() { color 7 "$@"; echo -n `tput sgr0`; } 12 + 13 + ARG1="$1" 14 + if [[ $ARG1 ]]; then 15 + output=$(eval "$@") 16 + 17 + echo "$output" 18 + echo "$output" | pbcopy -selection clipboard 19 + else 20 + FILENAME=${0##*/} 21 + echo "" 22 + echo "`green $FILENAME:`" 23 + echo " Run a command and copy the output to the clipboard." 24 + echo " For example, run `cyan copy pwd` to copy the current path." 25 + echo "" 26 + echo "`green Usage:`" 27 + echo " $FILENAME <command> [args...]" 28 + echo "" 29 + # Example: copy pwd" 30 + 31 + fi