55# Dependencies: jq, curl, w3m
66#
77
8- version=1.1.9
8+ version=1.2.0
99
1010# By default 'tmpmail' uses 'w3m' as it's web browser to render
1111# the HTML of the email
1212browser=" w3m"
1313
14+ # The default command that will be used to copy the email address to
15+ # the user's clipboard when running 'tmpmail --copy'
16+ copy_to_clipboard_cmd=" xclip -selection c"
17+
1418# If the value is set to 'true' tmpmail will convert the HTML email
1519# to raw text and send that to stdout
1620raw_text=false
@@ -48,8 +52,13 @@ the inbox and their numeric IDs. When called with one argument, tmpmail
4852shows the email message with specified ID.
4953
5054-b, --browser BROWSER
51- Specify BROWSER (default: w3m) that is used to render the HTML of
52- the email
55+ Specify BROWSER that is used to render the HTML of
56+ the email (default: w3m)
57+ --clipboard-cmd COMMAND
58+ Specify the COMMAND to use for copying the email address to your
59+ clipboard (default: xclip -selection c)
60+ -c, --copy
61+ Copy the email address to your clipboard
5362-g, --generate [ADDRESS]
5463 Generate a new email address, either the specified ADDRESS, or
5564 randomly create one
@@ -279,6 +288,11 @@ view_recent_email() {
279288 view_email " $mail_id "
280289}
281290
291+ copy_email_to_clipboard (){
292+ # Copy the email thats being used to the user's clipboard
293+ $copy_to_clipboard_cmd < $tmpmail_email_address
294+ }
295+
282296die () {
283297 # Print error message and exit
284298 #
@@ -297,7 +311,15 @@ main() {
297311 # dep_missing allows us to keep track of how many dependencies the user is missing
298312 # and then print out the missing dependencies once the checking is done.
299313 dep_missing=" "
300- for dependency in jq $browser curl; do
314+
315+ # The main command from $copy_to_clipboard_cmd
316+ # Example:
317+ # xclip -selection c
318+ # ├───┘
319+ # └ This part
320+ clipboard=${copy_to_clipboard_cmd%% * }
321+
322+ for dependency in jq $browser $clipboard curl; do
301323 if ! command -v " $dependency " > /dev/null 2>&1 ; then
302324 # Append to our list of missing dependencies
303325 dep_missing=" $dep_missing $dependency "
@@ -333,6 +355,8 @@ main() {
333355 case " $1 " in
334356 --help | -h) usage && exit ;;
335357 --generate | -g) generate_email_address true " $2 " && exit ;;
358+ --clipboard-cmd) copy_to_clipboard_cmd=" $2 " ;;
359+ --copy | -c) copy_email_to_clipboard && exit ;;
336360 --browser | -b) browser=" $2 " ;;
337361 --text | -t) raw_text=true ;;
338362 --version) echo " $version " && exit ;;
0 commit comments