I try to have the volume keys working on my laptop in pure console mode (Debian installed without X).
I can manage sound volume with alsa commands, but I'd like to assign them to those keys.
I know keycode thanks to the showkey command, but now I can't figure out where to assign a specific command to them. Is it in keymaps ? How ?
Thanks a lot
In bash, you can use bind e.g.
bind -x '"\C-g": ls'
will make ctrl-g run the ls command
Related
For the life of me I can't seem to figure out why ctrl-p and ctrl-n don't work like they're supposed to under the Docker images I have been working with.
ctrl-p should work just like the up arrow but I usually have to press it twice to get the last command I ran. And it cycles through the history in what seems to be a random fashion.
Maybe someone can help me make some sense of this.
docker run -it buildpack-deps:trusty # run a Linux based image
root#74cbcf321fae:/# ls
bin boot dev etc home lib lib64 ...
root#74cbcf321fae:/# touch hello
If I press up here, it should show the touch command, followed by ls.
If I press Ctrl-p however, nothing comes up the fist time. When I press it again, ls appears magically.
Can someone help me make sense of these. I can't live without Ctrl-p and Ctrl-n.
It looks like this has been removed (or moved) in the Docs, but it used to live here: https://docs.docker.com/engine/reference/commandline/attach/
Edit: It looks like they reference the below in the Configuration Files documentation.
The command sequence to detach from a docker container is ctrl-p ctrl-q, which is why ctrl-p doesn't work as expected. When you hit ctrl-p, docker is waiting on ctrl-q, so nothing happens.
You can use the new --detach-keys argument to docker run to override this sequence to be something other than ctrl-p:
docker run -ti --detach-keys="ctrl-#" ubuntu:14.04 bash
$# ls
$# <--- Ctrl-P here will display ls now
$# <--- Ctrl-# here will detach from the running container
If you want, you can add this to your ~/.docker/config.json file to persist this change:
{
...
"detachKeys": "ctrl-#",
...
}
More details on this can be found here: https://github.com/docker/docker/pull/15666 as I can't find it in the docs anymore.
I am trying to write a bash script to automate running some commands. However some of these commands should be running in their own terminal tab.
So I use the following in my bash script to open a new tab:
xdotool key ctrl+shift+t
this does the job, but the next commands in my bash script are still executed in the previous terminal tab.
How can I make the new opened terminal tab active and run the next commands in this tab?
What Terminal Emulator are you using? It strongly depends on this.
In general, you could write the commands you want to execute in a shell script and tell your terminal emulator to execute the script once it has started.
Example with xterm:
echo '#!/bin/bash' > /tmp/thescript
echo 'ls -la' >> /tmp/thescript
chmod +x /tmp/thescript
xterm -hold -e /tmp/thescript
EDIT: I just saw that u asked for a way to achieve this with xdotool. So this answer might be invalid. Please tell me if so - then i'll delete it.
How are you using xdotool? It can be done with a chain, for example:
$ xdotool key "ctrl+shift+t"; xdotool type "ls"; xdotool key Return
If all you want is to run the commands in the background / in parallel, without synchronously waiting for each command to complete before the next begins, terminate them with an ampersand & to instruct the shell to do so.
Alternatively, you can execute the commands in their own subshells by surrounding each with parentheses ( ). If they are long running processes or you do not wish to pollute the original shell with their output, you can fork them off and capture their output to file with something like (setsid command 1>/path/to/log &).
If separate tabs is necessary requirement, you can use xdotool to key the switch-to-the-next-tab binding or similar, and then key the commands you must run in that tab.
Instead of sorting out that mess yourself, you could use a script from this answer by Jacob Vlijm, which wraps a windowed approach that uses xdotool and wmctrl to 'send' commands to different terminal windows. The script is written in python 3 but it can easily be rewritten for a shell environment of choice.
A more direct approach involves use of a TIOCSTI ioctl to inject characters into another terminal. According to the tty_ioctl manual page:
NAME
ioctl_tty - ioctls for terminals and serial lines
...
DESCRIPTION
The ioctl(2) call for terminals and serial ports accepts many possible
command arguments.
...
Faking input
TIOCSTI const char *argp
Insert the given byte in the input queue
...
Here are c and perl wrappers, and an example in python as referenced by this answer.
I'm ssh-ing into a remote machine and when I try to search my history in a linux terminal with reverse-i-search, nothing happens. I press ctrl-r as I usually do on my machine, but the prompt doesn't appear.
Any ideas? How can I check the keybindings for ctrl-r? How do I set them if they aren't set? Do I have to apt-get reverse-i-search functionality?
Thanks!
To use ctrl-r your shell needs to be using readline (or something similar), your history should be collected.
So you should verify your shell for example sh doesn't support this.
You should check it the history is collected. For example with bash shell: echo $HISTFILE
I think these can be the main reasons.
Hopefully with simply entering bash, you can switch to a proper shell which will support this.
Trying to get up and running Vim + Rebar.
Separately they work but not together. What I want to achieve is to run eunit without leaving the Vim.
I guess this is doable with following plugin https://github.com/mbbx6spp/vim-rebar . Unfortunately is very poorly documented.
How do I run my tests quickly, see the output, code and once again.
All your feedback will be appreciated.
I don't know how to integrate rebar into vim, but perhaps you could try tmux? This works for me. In one window I keep opened vim, another window i use as compilation/attach session to erlang node.
One quick way to get out of Vim is to suspend it with Ctrl+z, run your commands, and then foreground it again with fg afterwards. Works at least on bash in Os X and Ubuntu Linux.
You can also run command line commands with :! <command name> directly from Vim, e.g. :! ls.
Yet another way is to use screen, with one window running vim and another still on the command line.
The best solution I've found is to use a Makefile in my project. Since vim is capable of running shell commands, you can call make & have it use your makefile. Then map these shell commands to shortcuts of your choosing.
For example, my Makefile has the following:
test:
$(REBAR) skip_deps=true eunit
In my .vimrc:
command MakeErlangTest !make test
nmap <leader>r :MakeErlangTest<CR>
I am trying to use rxvt on my cygwin w win XP but the terminal appears and disappears. What could be wrong? This is true for all except rxvt-native . I have tried a few commands found online but with no success. I include 2 I have tried:
start C:\cygwin\bin\rxvt.exe -sb -sl 3000 -fg gray -bg black -fn "Lucida Console-14" -e /bin/bash --login -i
.
path C:\cygwin\bin;%path%
ssh-agent rxvt -e bash --login -i
Another problem I am facing is trying to get vi to work in my cygwin bash shell. Setting term to xterm or vt100 does not work. Hitting enter, I see a string 78 or some other issue pops up. I have never modified my .inputrc.
My main issue was trying to get vi to work properly. I just found out that if I run
/etc/postinstall/terminfo.sh.done , I can now navigate properly in vi. The 78 (newline) M still appears but at least I can navigate in vi.
Feb 25 - This problem went away after a few windows updates. Would it make sense to ANSWER my question on the basis that this is longer reproducible?
Can't answer the first question, but have you tried invoking rxvt from its shortcut in the Cygwin folder of the start menu?
Regarding the second question, the TERM variable tells applications what terminal they're running in, so if you set it to 'xterm' while running in the Cygwin console (where normally TERM=cygwin), they'll be sending xterm control sequences that the Cygwin console doesn't understand. So basically: don't do that!
Btw, you might also be interested in Cygwin's mintty package, which is another terminal that doesn't need an X server. Installing it also creates a start menu shortcut in the Cygwin folder.
I would assume you need an X server running.
You could install Cygwin/X
One thing which may not have been clear was that the whole exercise was to get vi to work. vim did not work either at that time. But after some windows update, the problem went away. Closing it...