I use vi keybindings in Tmux's copy-mode, and I'd like to make Esc clear the current selection if there is one, or exit copy-mode if nothing was selected.
bind -T copy-mode-vi Escape if-shell -F '#{selection_active_flag}' \
'send-keys -X clear-selection' \
'send-keys -X cancel'
I was hoping Tmux might expose a variable that indicates the selection state (I made up selection_active_flag to express my intent, it doesn't actually exist), similar to window_zoomed_flag (which does exist).
Is there a way to achieve this?
Tmux 2.6 introduced selection_present. As stated in the changelog,
Add selection_present format when in copy mode (allows key bindings that do
something different if there is a selection).
This is exactly what I was looking for, and though I'm running Tmux 2.6, it seems I have an outdated man page, as it made no mention of selection_present.
The final working solution is:
bind -T copy-mode-vi Escape if-shell -F '#{selection_present}' \
'send-keys -X clear-selection' \
'send-keys -X cancel'
Related
makefile looks like below
BASE_JOB_IMAGE := $(shell ./fetchimageversion.sh >> image.txt)
FILE ?= image.txt
BASE_JOB_IMAGE_NAME=`cat $(FILE)`
docker build \
--pull \
--no-cache \
-t ${APPLICATION}_${TF_VER} \
--build-arg baseimage=$(BASE_JOB_IMAGE_NAME)
But I am not getting the expected output in travis logs.
docker build \
--pull \
--no-cache \
--build-arg baseimage=`cat image.txt` \
When used as BASE_JOB_IMAGE := $(shell ./fetchimageversion.sh) I do see the output of the script
output but whole script execution result is set to the variable which also result in error in travis log wihth --build-arg baseimage= \ being blank
First that can't be the makefile; you have a target with no recipe. I assume that the docker command is in a recipe. Please be sure to provide enough of an example to constitute a functional test.
Second, when you run make what output do you see? When asking for help it's best to include the command you typed, the output you got (if it's a lot of output at least show the errors and few lines before it), and explain what you wanted. You should cut and paste this into your question: don't use screenshots and don't paraphrase/retype it where you might introduce subtle differences that might completely change the possible problem.
Third, why do you write the output to a static file but then set a variable and refer to the variable for the rest of the makefile?
Fourth, why do you use ?= to define the filename? Do you expect to want to allow an environment variable to override the filename? That won't work if you're writing to a static filename in the previous command.
Fifth, why are you using append-to >> when writing the file? If the file already exists this means you'll have multiple lines of content in it.
Try writing your makefile like this:
FILE = input.txt
BASE_JOB_IMAGE := $(shell ./fetchimageversion.sh >$(FILE))
BASE_JOB_IMAGE_NAME = `cat $(FILE)`
...rest of makefile...
and if that doesn't work, please provide more details as discussed in the first two paragraphs.
ETA
But, I don't know why you're going through this extra effort of writing to a file. Why not just keep the output in a variable?
BASE_JOB_IMAGE_NAME := $(shell ./fetchimageversion.sh)
...rest of makefile...
I need to bind the code 127 (aka DEL, aka ^?) to delete-char.
If I put DEL: delete-char to ~/.inputrc, it does not work. This is because this code is used by backward-delete-char by default.
So, first I need to free this code from backward-delete-char:
$ bind -u backward-delete-char
But for some reason it is not unset:
$ bind -q backward-delete-char
backward-delete-char can be invoked via "\C-?".
What should be changed in source code of readline library (for local use) to unbind the \C-? from backward-delete-char?
N.B. If I unset for example delete-char, it works flawlessly:
$ bind -u delete-char
$ bind -q delete-char
delete-char is not bound to any keys.
Running GNU bash, version 4.4.19(1)-release (x86_64-apple-darwin16.6.0) I see the same thing. I am able to unset the one I wanted with this: bind -m emacs-meta -u backward-kill-word
According to the maintainer Chet:
Unless you use the -m' option, the commands act on the current keymap, which is eitheremacs' or (usually) `vi-insert'
I found that his example commands didn't quite work, and only -m emacs-meta worked - but I'm not sure how to discover precisely which keymap applies.
Discovery process: searched the mailing list (Googled and site:http://lists.gnu.org/archive/html/bug-bash/ "bind -u") and picked up:
Re: Some readline functions can't be unbound with bind -u
I am new the Erlang. Currently, we are using ejabberd for our xmpp service.
Recently, dues to some capability issue, I have written a distributed erlange program. I need to run rpc:call between two machines. I can do the rpc:call successfully on erl simulator. But our current system was using ejabberdctl to start the ejabberd service. I have check and try to modify the ejabberdctl file. But I can't add -setcookie successfully.
the code section in ejabberdctl is
ctlexec()
{
CONN_NAME=$1; shift
COMMAND=$#
$EXEC_CMD "$ERL \
$NAME ${CONN_NAME} \
-noinput \
-hidden \
-pa $EJABBERD_EBIN_PATH \
$KERNEL_OPTS \
-s ejabberd_ctl -extra $ERLANG_NODE $COMMAND"
}
the problem caused by the last two line:
$KERNEL_OPTS \
-s ejabberd_ctl -extra $ERLANG_NODE $COMMAND"
I think this file is referenced some one's before, but I don't know where are there from.
Does anybody know how can I add -setcookie abc to this erl command?
If I can't change the ejabberdctl file or the worse case, I can't change the current system.
i.e. I don't have a chance to add setcookie to the ejabberd system.
How can I connect my new node to the existing ejabberd node(our current system).
The ejabberd suppose to start first.
You have a solution right under your nose. How ctlexec() works? It runs --hidden node named $NAME ${CONN_NAME}, sets options $KERNEL_OPTS, inserts $EJABBERD_EBIN_PATH into search path and calls ejabberd_ctl:start() with some additional parameters in $ERLANG_NODE $COMMAND. So there must be -setcookie Cookie parameter in $KERNEL_OPTS or it uses default cookie in $HOME/.erlang.cookie. It is exactly what you need. Just replace -s ejabberd_ctl with your own module and use $KERNEL_OPTS and $ERLANG_NODE content which you already have. Search around in the script for clues what $KERNEL_OPTS and $ERLANG_NODE contains.
It is a usual way how scripts like ejabberd_ctl are made. It is pretty simple and elegant. You just run your own node set it --hidden so you don't disturb other nodes in a cluster if there is such. Don't forget set some random node name. Connect to the application node and then do your rpc:call/4,5 and that's it. There is usually some modules like ejabberd_ctl.erl to make it more comfortable, process extra parameters and so on.
I have a training.arff file, where each entry has 2000 features (attributes). I want to select the top n of those attributes using the Information Gain criteria. How can I do that using WEKA and the command line? I have checked online and it seems that it is a two stage process, because I have to use a ranker as the second step. Could someone explain me how to do it?
The way to do it is this:
java weka.filters.supervised.attribute.AttributeSelection \
-E "weka.attributeSelection.InfoGainAttributeEval" \
-S "weka.attributeSelection.Ranker -N 10" -i training.arff -o training_IG.arff
The -E option is to tell which class to use as evaluator, and the -S tells what search method to use (in this case ranking).
This question is based on this answer.
Why do you get the same output from the both commands?
Command A
$sudo grep muel * /tmp
masi:muel
Command B
$sudo grep -H muel * /tmp
masi:muel
Rob's comment suggests me that Command A should not give me masi:, but only muel.
In short, what is the practical purpose of -H?
Grep will list the filenames by default if more than one filename is given. The -H option makes it do that even if only one filename is given. In both your examples, more than one filename is given.
Here's a better example:
$ grep Richie notes.txt
Richie wears glasses.
$ grep -H Richie notes.txt
notes.txt:Richie wears glasses.
It's more useful when you're giving it a wildcard for an unknown number of files, and you always want the filenames printed even if the wildcard only matches one file.
If you grep a single file, -H makes a difference:
$ grep muel mesi
muel
$ grep -H muel mesi
masi:muel
This could be significant in various scripting contexts. For example, a script (or a non-trivial piped series of commands) might not be aware of how many files it's actually dealing with: one, or many.
When you grep from multiple files, by default it shows the name of the file where the match was found. If you specify -H, the file name will always be shown, even if you grep from a single file. You can specify -h to never show the file name.
Emacs has grep interface (M-x grep, M-x lgrep, M-x rgrep). If you ask Emacs to search for foo in the current directory, then Emacs calls grep and process the grep output and then present you with results with clickable links. Clickable links, just like Google.
What Emacs does is that it passes two options to grep: -n (show line number) and -H (show filenames even if only one file. the point is consistency) and then turn the output into clickable links.
In general, consistency is good for being a good API, but consistency conflicts with DWIM.
When you directly use grep, you want DWIM, so you don't pass -H.