How do I feed a command with arguments to Bash?


d3pd

I need to type a UTC timestamp (like "2017-01-25T1422Z") very regularly, so I set it as a shortcut key in Ubuntu ( Ctrl+ Shift+ d) . Specifically, the custom shortcut keys are set to the following commands:

bash /home/user/scripts/type_time_UTC.sh

The script type_time_UTC.shcontains the following:

#!/bin/bash

xvkbd -text $(date "+%Y-%m-%dT%H%MZ" --utc)

How should I edit the shortkey command so that no script is required?

塞尔吉(Sergiy Kolodyazhnyy)

First, the shortcut you're trying to set is CtrlShiftDoften used by other programs, so I'd recommend using the other way around.

Second, on my system, when I run the command you specified, it outputs false warnings, specifically the following:

xvkbd: Mode_switch not available as a modifier
xvkbd: although ISO_Level3_Shift is used instead, AltGr may not work correctly

So we might want to use 2> /dev/nullredirection to get rid of that one .

As for setting the keyboard shortcut itself, it should be enough

bash -c "xvkbd -text $(date "+%Y-%m-%dT%H%MZ" --utc) 2>/dev/null" 

and set it to a key combination that doesn't interfere with the application. Personally, I would use Ctrl++ Super(Win key), Jwhich is unused, but the choice is up to you. For example , I bind mine to Ctrl++Super(Win key)P

enter image description here

Related


How do I feed a command with arguments to Bash?

d3pd I need to type a UTC timestamp (like "2017-01-25T1422Z") very regularly, so I set it as a shortcut key in Ubuntu ( Ctrl+ Shift+ d) . Specifically, the custom shortcut keys are set to the following commands: bash /home/user/scripts/type_time_UTC.sh The sc

How do I pass arguments to the "source" command?

newbie My sourcecommand in CShell looks like this: source /directory/of/script/script.csh Between script.cshexecution and my password awaits confirmation of identity. I'm tired of having to enter my password every time source. So since my password is constant

How do I pass arguments to the "source" command?

newbie My sourcecommand in CShell looks like this: source /directory/of/script/script.csh Between script.cshexecution and my password awaits confirmation of identity. I'm tired of having to enter my password every time source. So since my password is constant

How can I escape arguments passed in bash script command line

master: I have a variable which comes from somewhere: VAR1='hhgfhfghhgf"";2Ddgfsaj!!!$#^$\'&%*%~*)_)(_{}||\\/' Now I have a command like this ./myscript.sh '$VAR1' I got $VAR1 from some comparisons and when I display it it looks exactly like above. Now the c

How can I recall the arguments of the previous bash command?

Coder: Is there any way in Bash to recall the arguments of the previous command? I usually vi file.cfollow gcc file.c. Is there any way in Bash to recall the arguments of the previous command? coding: You can use $_or !$call the last parameter of the previous

How can I escape arguments passed in bash script command line

master: I have a variable which comes from somewhere: VAR1='hhgfhfghhgf"";2Ddgfsaj!!!$#^$\'&%*%~*)_)(_{}||\\/' Now I have a command like this ./myscript.sh '$VAR1' I got $VAR1 from some comparisons and when I display it it looks exactly like above. Now the c

How can I recall the arguments of the previous bash command?

Coder: Is there any way in Bash to recall the arguments of the previous command? I usually vi file.cfollow gcc file.c. Is there any way in Bash to recall the arguments of the previous command? coding: You can use $_or !$call the last parameter of the previous

How to redirect a command with arguments in bash?

Rohan Hasabnis rpm -qf /etc/redhat-releaseI want to output "hello" when typing . Otherwise, the rpm should work fine. Jeff Schaller Doesn't seem to be of much use, but a function can be used for the purpose: rpm() { if [ "$1" = "-qf" ] && [ "$2" = "/etc/redh

How do I pass arguments to a command in a PowerShell script?

Hendre I want to execute a Java command: java -jar cli.jar <arg> <arg>from inside a PowerShell script. How do I pass command line arguments passed to a PowerShell script to a Java command inside the script? clumsy puffin If you want to pass command line argume