Add clipboard mode.
This commit is contained in:
		| @@ -16,6 +16,8 @@ Copy `mbin.sh` to your PATH or add an alias to point to the absolute path of | |||||||
| ```bash | ```bash | ||||||
|   some_command | mbin.sh |   some_command | mbin.sh | ||||||
|   mbin.sh # Opens in interactive mode. |   mbin.sh # Opens in interactive mode. | ||||||
|  |   mbin.sh -c # Posts clipboard contents to bin | ||||||
|  |   mbin.sh --clipboard # Posts clipboard contents to bin | ||||||
| ``` | ``` | ||||||
|  |  | ||||||
| ## Customization | ## Customization | ||||||
|   | |||||||
							
								
								
									
										5
									
								
								mbin.sh
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								mbin.sh
									
									
									
									
									
								
							| @@ -5,7 +5,10 @@ | |||||||
| MKR_BIN=${MKR_BIN:-https://bin.mkr.pw/} | MKR_BIN=${MKR_BIN:-https://bin.mkr.pw/} | ||||||
| EDITOR=${EDITOR:-vim} | EDITOR=${EDITOR:-vim} | ||||||
|  |  | ||||||
| if [ -t 0 ]; then | if [[ $1 == "-c" || $1 == "--clipboard" ]]; then | ||||||
|  |   text=$(xclip -selection clipboard -out) | ||||||
|  |   op=$(curl -s --data-binary "${text}" -H "Content-Type:text/plain" $MKR_BIN) | ||||||
|  | elif [ -t 0 ]; then | ||||||
|   tmp_file=$(mktemp) |   tmp_file=$(mktemp) | ||||||
|   $EDITOR $tmp_file |   $EDITOR $tmp_file | ||||||
|   op=$(curl -s --data-binary "@${tmp_file}" -H "Content-Type:text/plain" $MKR_BIN) |   op=$(curl -s --data-binary "@${tmp_file}" -H "Content-Type:text/plain" $MKR_BIN) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user