Unknown option: %{strftime("%c")}%=0x%B\\ - vim

I have write the code according to book*learning vi and vim* p202
set statusline=%<%t%h%m%r\ \ %a\ %{strftime(\"%c\")}%=0x%B\
\\ line:%1,\ \ col:%c%V\ %P
i write the sentence in my _vimrc ,when i open a file ,an mistake occur .
Unknown option: %{strftime("%c")}%=0x%B\\
what is the matter?

Just before the %{strftime, you have two space characters, and only the first one is properly escaped with \. Therefore, Vim thinks the option value ends there and another option name begins. You need to either remove that additional space, or escape it (same for later occurrences of multiple spaces):
set statusline=%<%t%h%m%r\ \ %a\ \ %{strftime(\"%c\")}%=0x%B\
\\ \ line:%1,\ \ \ \ col:%c%V\ %P
As this is cumbersome and hard to read and edit, an alternative is to use :let, which avoids that escaping:
let &statusline = '%<%t%h%m%r %a %{strftime("%c")}%=0x%B line:%1, col:%c%V %P'

Related

HaplotypeCaller provide variants more than expected

I used HaplotypeCaller for variant calling out of WES picard.sorted.MarkedDup.bam file with GATK 4.2.6.1. HaplotypeCaller standard command line.
Apparently, everything worked well and I received standard .vcf file. But the number of identified variants are too much for WES result. It's close to one million variants for one sample!
Did I perform something wrong?
What solution do you recommend?
Any help would be appreciated.
The command line I used was as follow:
gatk --java-options -Xmx8g HaplotypeCaller \ -R $refFile \ -I ${base}.picard.sorted.markedDup.bam \ --dont-use-soft-clipped-bases -stand-call-conf 20.0 \ --emit-ref-confidence GVCF \ -O ${base}.rrrrealigned.vcf

How to use right the dialog command in the sh script? [duplicate]

This question already has answers here:
Why does shell ignore quoting characters in arguments passed to it through variables? [duplicate]
(3 answers)
Closed 5 years ago.
I wrote some script:
#!/bin/sh
dialog --menu \
"Please select a partition from the following list to use for your \
root (/) Linux partition." 13 70 3 \
"/dev/hda2" "Linux native 30724312K" "/dev/hda4" "Linux native 506047K"
DISKS='"disk1" "50 Gb" "disk2" "100 Gb"'
dialog --menu \
"Please select a partition from the following list to use for your \
root (/) Linux partition." 13 70 3 \
$DISKS
The first call looks good.
The second call looks bad.
I need to transmit information about the drives through the variable. Please tell me why the second version of the call does not work as expected?
Let's ask shellcheck:
$ shellcheck myscript
In myscript line 9:
DISKS='"disk1" "50 Gb" "disk2" "100 Gb"'
^-- SC2089: Quotes/backslashes will be treated literally. Use an array.
In myscript line 14:
$DISKS
^-- SC2090: Quotes/backslashes in this variable will not be respected.
The detailed error page offers an explanation:
Bash does not interpret data as code. Consider almost any other languages, such as Python:
print 1+1 # prints 2
a="1+1"
print a # prints 1+1, not 2
Here, 1+1 is Python syntax for adding numbers. However, passing a literal string containing this expression does not cause Python to interpret it, see the + and produce the calculated result.
Similarly, "My File.txt" is Bash syntax for a single word with a space in it. However, passing a literal string containing this expression does not cause Bash to interpret it, see the quotes and produce the tokenized result.
The solution is to use an array instead, whenever possible.
Ok, let's try that:
#!/bin/bash
DISKS=("disk1" "50 Gb" "disk2" "100 Gb")
dialog --menu \
"Please select a partition from the following list to use for your \
root (/) Linux partition." 13 70 3 \
"${DISKS[#]}"
This works.
However, this is a bash specific solution. If you want it to work for sh, in this case, you can pick a delimiter other than whitespace by setting the Internal Field Separator:
#!/bin/sh
IFS=":" # Split on colons
set -f # Prevent globbing
DISKS='disk1:50 Gb:disk2:100 Gb'
dialog --menu \
"Please select a partition from the following list to use for your \
root (/) Linux partition." 13 70 3 \
$DISKS
This also works as expected. If your script is longer than this, you'd want to set IFS back to its original value.

vim mapping K to external command

I'd like to map vim's 'keywordprg' to Dash, namely, use K to do !open dash://word-unser-curse.
Currently, I'm doing this:
:let &keywordprg '!open dash://'
but it says E34: No previous command.
from :h E34:
Any '!' in {cmd} is replaced with the previous
external command (see also 'cpoptions'). But not when
there is a backslash before the '!', then that
backslash is removed. Example: ":!ls" followed by
":!echo ! \! \\!" executes "echo ls ! \!".
Thus you have to escape ! in order to have vim treat as it is, otherwise vim tries to replace it with the "previous command", resulting in the error.
Additionally, I don't think you need that ! in your keywordprg. Vim calls it as an external command anyway (the default value is man, not !man).

File completion priorities in ZSH

I have a shell pattern that marks some files as "boring" namely backup files, pyo files, vim backups, autogenerated directories and the like. Let's call it $BORING_STUFF.
zstyle ':completion:*' file-patterns \
'%p:globbed-items' \
'*(^-/):regular-files' \
'*(^-/):boring-files' \
'.*(^-/):hidden-files' \
'*(-/):regular-directories' \
'*(-/):boring-directories' \
'.*(-/):hidden-directories'
In this case, I have the scope of each group also constrained by applicable ignore-patterns. (Such that boring-files contains only boring files and regular-files does not contain boring files)
I'd like bold items to always show up, and other items only show up if there are no other matches. (Aka. touch <tab> will show regular directories and regular files but not hidden files, while touch .<tab> will show hidden files.)
globbed items
directories
regular directories
boring directories
hidden directories
files
regular files
boring files
hidden files
Here we go.
setopt extended_glob
zstyle ':completion:*' file-patterns \
"^($BORING_FILES|.*)(-/):directories:normal\ directories %p~($BORING_FILES|.*)(^-/):globbed-files:normal\ files" \
"^($BORING_FILES|.*)(^-/):noglob-files:noglob\ files" \
".*~($BORING_FILES)(^-/):hidden-files:hidden\ files .*~($BORING_FILES)(-/):hidden-directories:hidden\ directories" \
"($BORING_FILES)(^-/):boring-files:boring\ files ($BORING_FILES)(-/):boring-directories:boring\ directories" \
zstyle ':completion:*' group-order \
builtins expansions aliases functions commands globbed-files \
directories hidden-files hidden-directories \
boring-files boring-directories keywords viewable

Export vim syntax highlighting to latex

I would like to exploit vim's syntax highlighting capabilities to highlight code (any language) in latex (using the xcolor package). Therefore I wonder if it is possible to have a vim-script export the vim internal information about the highlighted text in the buffer. Obviously it would be sufficient to know start, end and color of each highlighted entity. The generation of the latex code or other languages such as html would then be obvious.
You can use my formatvim plugin: it can export to latex-xcolor format with
Format format latex-xcolor
. If you are not fine with the result (it is completely untested and I almost never used this option) feel free to send patches, dictionary with format specification can be seen here, everything what you need to create your own format is in documentation.
Note: if you need to export to any other language all you need is to write a specification for it in terms of my plugin. Here is a code that will add latex-xcolor-clone format to my plugin:
scriptencoding utf-8
execute frawor#Setup('0.0', {'plugin/format': '3.0'})
let s:texescape=
\'substitute('.
\ 'substitute(###, ''\v[\\\[\]{}&$_\^%#]'', '.
\ '''\=''''\char''''.char2nr(submatch(0))."{}"'', '.
\ '"g"),'.
\'" ", ''\\enskip{}'', "g")'
let s:texstylestart=
\'((#inverse#)?'.
\ '(''\colorbox[HTML]{''.'.
\ '((#fgcolor#!=#"")?'.
\ '(toupper(#fgcolor#[1:])):'.
\ '(toupper(#_fgcolor#[1:])))."}{".'.
\ '''\textcolor[HTML]{''.'.
\ '((#bgcolor#!=#"")?'.
\ '(toupper(#bgcolor#[1:])):'.
\ '(toupper(#_bgcolor#[1:])))."}{"):'.
\ '(((#bgcolor#!=#"")?'.
\ '(''\colorbox[HTML]{''.toupper(#bgcolor#[1:])."}{"):'.
\ '("")).'.
\ '''\textcolor[HTML]{''.'.
\ '((#fgcolor#!=#"")?'.
\ '(toupper(#fgcolor#[1:])):'.
\ '(toupper(#_fgcolor#[1:])))."}{"))'
let s:texstyleend=
\'repeat("}", '.
\ '((#inverse#)?'.
\ '(2):'.
\ '((#bgcolor#!=#"")+1)))'
let s:format={
\'begin': '\documentclass[a4paper,12pt]{article}'.
\ '\usepackage[utf8]{inputenc}'.
\ '\usepackage[HTML]{xcolor}'.
\ '\pagecolor[HTML]{%''toupper(#_bgcolor#[1:])''%}'.
\ '\color[HTML]{%''toupper(#_fgcolor#[1:])''%}'.
\ '\begin{document}{\ttfamily\noindent',
\'line': '%>'.s:texstylestart.".".
\ s:texescape.".".
\ s:texstyleend,
\'lineend': '\\',
\'end': '}\end{document}',
\'strescape': s:texescape,
\}
call s:_f.format.add('latex-xcolor-clone', s:format)
The :TOhtml command is built in Vim. It, rather obviously, generates HTML, not Latex, though.

Resources