what option controls numeric brace expansion in zsh? - zsh

I'm getting a really weird bug on one of my zsh installations. I can do this:
for k in {1..6}; do echo $k; done
# 1
# 2
# 3
# 4
# 5
# 6
but I can't step through it:
for k in {1..6..2}; do echo $k; done
# {1..6..2}
I'm sure my current shell is zsh, and in a different computer it works, so I'm just wondering what option I might have set that changed the default behavior. Any ideas?

While the {x..y} syntax originated in zsh decades ago, ksh93 was the one adding the {x..y..step} one and zsh only added it in version 4.3.10-test-3 in 2010.
You probably have an older version of zsh there.

Related

How to run multiple julia files parallel?

I have a pretty simple question but I can't seem to find an answer anywhere. I want to run two .jl files parallel using the Julia Terminal.
I tried include("file1.jl" & "file2.jl") and include("file1.jl") & include("file2.jl") but this doesn't work.
I'm not sure exactly what you want to do but if you wanted to run these two files on two different workers from the julia terminal you could for e.g.
addprocs(1) # add a worker
pmap(include,["file1.jl", "file2.jl"]) # apply include to each element
# of the array in parallel
But I'm pretty sure there will be a better way of doing whatever you want to accomplish.
While you can probably wrangle your code into the Julia parallel computing paradigms, it seems like the simplest solution is to execute your Julia scripts from the command line. Here I assume that you are comfortable allowing your CPU to handle the task scheduling, which may or may not result in parallel execution.
What follows below is a skeleton pipeline to get you started. Replace task.jl with your file1.jl, file2.jl, etc.
task.jl
println("running like a cheetah")
run_script.sh
echo `date`
julia task.jl
julia task.jl
echo `date`
run_script_parallel.sh
echo `date`
julia task.jl &
julia task.jl &
wait # do not return before background tasks are complete
echo `date`
From the command line, ensure that your BASH scripts are executable:
chmod +rwx run_script.sh run_script_parallel.sh
Try running the scripts now. Note that my example Julia script task.jl returns almost immediately, so this particular comparison is a little silly:
./run_script.sh
./run_script_parallel.sh
My output
Thu Jan 5 14:24:57 PST 2017
running like a cheetah
running like a cheetah
Thu Jan 5 14:24:57 PST 2017
Thu Jan 5 14:25:05 PST 2017
running like a cheetahrunning like a cheetah
Thu Jan 5 14:25:06 PST 2017
The first output orders the print statements in a clean serial order. But observe in the second case that the text is running together. That is common behavior for parallel print statements.

Zsh + tmux + oh-my-zsh: Autocomplete produces remnant characters

I recently installed Zsh in hope of a better life and brighter mornings. However, I quickly realized Zsh introduces various issues in conjunction with tmux.
The first issue was some weird stuff happening at the end of the prompt, before my commands, but this was resolved by supplying tmux with the -u flag for unicode-support. However, I am stuck with one final issue that needs resolution before I can use Zsh with tmux:
Usecase: Autocomplete a command which contains multiple suggestions
Issue: Autocompletion shifts suggestion one character to the right, while leaving the original character behind (visual bug, it is not included in the command)
Example 1.
Then I hit TAB..
Example 2.
Then I hit TAB..
Note 1: This does NOT occur when using the Bash-shell.
Note 2: I am using "oh-my-zsh". This issue only occurs when using the provided themes. This narrows it down to an "oh-my-zsh"-theme issue, not native zsh/tmux.
In case some people still get a similar issue, see also the top-voted answer of Remnant characters when tab completing with ZSH. The plugin you were using may have had the same non-printable characters issue, that would explain the symptoms.

history search backward in R

Normally in my machine I can search R's history backwards by typing the desired first characters of the command I want to backward-search and then use the PageUp or PageDown keys to go through all the entries in the R history.
I am working as a guest in a remote cluster now and this option is not available in this machine.
Does anyone have an idea of where can I add this function to R?
EDIT: I am interested on key bindings rather than how to reproduce this function.
EDIT2: I am locally on a Fedora 16 machine; remotely CentOS release 5.3 (Final)
history(pattern="lm\\(") # finds lines with lm or glm calls
There are a variety of history mechanisms and it may be that what your console is looking at will not be the same as that which the history call will be accessing. Read the Details section of the ?history page.
I found where to look at in order to tell R how to behave.
The key was to modify my ~/.inputrc file as it is the reference for R's input method.
I used the same file from my local Fedora 16 /etc/inputrc and copied it into the remote cluster as ~/.inputrc. The file looks like this
# do not bell on tab-completion
#set bell-style none
set meta-flag on
set input-meta on
set convert-meta off
set output-meta on
# Completed names which are symbolic links to
# directories have a slash appended.
set mark-symlinked-directories on
$if mode=emacs
# for linux console and RH/Debian xterm
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# commented out keymappings for pgup/pgdown to reach begin/end of history
#"\e[5~": beginning-of-history
#"\e[6~": end-of-history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e[1;5C": forward-word
"\e[1;5D": backward-word
# for rxvt
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
"\eOH": beginning-of-line
"\eOF": end-of-line
# for freebsd console
"\e[H": beginning-of-line
"\e[F": end-of-line
$endif

vim multiple matches. 2mat, 3mat, matchadd() alternatives

I want to have highlights for multiple words. i normally do this in .vimrc-
:highlight HLONE ctermbg=grey ctermfg=white
:highlight HLTWO ctermbg=blue ctermfg=white
:highlight HLTHREE ctermbg=green ctermfg=white
nnoremap 1 :mat HLONE "<C-R><C-W>"<CR>
nnoremap 2 :2mat HLTWO "<C-R><C-W>"<CR>
nnoremap 3 :3mat HLTHREE "<C-R><C-W>"<CR>
But its not working for me at my current workplace for some reason. Presessing one highlights the way it should. but pressing 2 (2mat) gives error -
E481: No range allowed
its seems 2mat, 3mat, matchadd are not available. vim version is 6.3.
is there any workaround or alternative?
Vim 6.3 is from 2004; the :2match commands were only introduced in Vim 7.0. If you're stuck with that version, you can only use :match, or alternatively try :syn keyword (but that will interfere with the regular syntax highlighting).
Even without root / administrative rights, you can usually compile / install a local version of Vim.
Advertisement: If you find the multi-word highlighting indispensable and use it often, try out my Mark plugin; it automates the process of :2match, offers many colors, and highlights in all windows (but requires Vim 7.2). On that page are also links to other such plugins, some of which still use syntax highlighting and may work even with Vim 6.

Why do programs in Unix-like environments have numbers after their name? [duplicate]

This question already has answers here:
What does the number in parentheses shown after Unix command names in manpages mean?
(7 answers)
Closed 4 years ago.
For example, when I run man ioctl the page says IOCTL(2) at the top. What does that mean? Is there an IOCTL(1)? And how does one navigate between these?
It's the man page section. From memory, section 1 is user programs, 2 is system calls, and 3 is standard C library calls, and 5 is file formats.
Wikipedia has the full explanation here.
That's the man page section number. For example
man printf
(should) Give you section 1, printf the bash command, while
man 3 printf
gives you the C function printf.

Resources