Zsh is a shell with many advanced command-line and scripting features.

learn more… | top users | synonyms (1)

0
votes
0answers
24 views

Use zsh to delete glob-matched files that have dollar sign ($) in name [on hold]

I have several files in a directory where the filename contains a dollar sign ($), for example: foo$bar.class I want to delete all of the files that end in .class. However, with zsh, the usual way ...
0
votes
0answers
36 views

Code for creating charts from csv data in shell - pure scripting

I am running mysql queries and put the data in csv file and mailing the same using shell script.[This is an automated script] I want to create a chart out of the csv data and put it in the mail body ...
13
votes
1answer
561 views

What's the magic that allows me to tab-complete remote files as I type an scp command?

Presumably this is a feature provided by some plugin I have enabled in my oh-my-zsh setup (I have been using zsh for many years now). I noticed ever since I added my public key to the server (now I ...
0
votes
1answer
47 views

Cannot get interface information using read

The following link has a script to get system information: z3bra' blog Specifically, network() { read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'` if iwconfig ...
2
votes
2answers
58 views

Reliably identifying the path to the directory containing the running script

There are plenty of answers in SO to address this question: Can a Bash script tell what directory it's stored in? Unix shell script to find out which directory the script resides? And there are a ...
0
votes
1answer
20 views

A generic cron wrapper that records all output

I am hoping to write a cron wrapper that records all output in a folder $CRON_LOG_DIR. It would be used as, e.g., follows: * * * * * $CRON_WRAPPER "<job name>" "command" which would record ...
0
votes
1answer
15 views

How to solve nsf-common related error when install zsh in ubuntu?

Everytime I install some kind of package, at the last phase, apt-get install could return a common-nfs related error. Why the installation can't be done without this error? detailed pastebin here ...
0
votes
1answer
23 views

zsh alias with linefeeds, commas and quotes

In my zshrc I have an alias like this: alias sl='screen -list' It fits my need (seeing what screens I have running), but the output is rather ugly: [pts/7]~% sl There are screens on: ...
2
votes
1answer
33 views

Clustering identical files ignoring spaces & linebreaks

Consider a folder with many XML files (10K small text files). Some XML files are identical, some are different. I would like to find out what files are identical (ignoring whitespaces, tabs and ...
2
votes
2answers
31 views

Replace screen process from within screen

I have configured my shell to exec screen when it starts, unless it's already running within a screen session. So in a TTY, the process tree will look like something like this: ...
0
votes
2answers
41 views

Best way to kill processes in a list

I've got this zsh script. Is there a more a graceful way to do this? export PROCESSES_TO_QUIT='puma rake sidekiq spring rails ruby-debug phantomjs zeus passenger guard resque "node server.js"' pgr() ...
3
votes
1answer
42 views

echo result from subshell in zsh

In zsh, the following 2 commands results differently: a=$(</etc/hosts) && echo $a echo $(</etc/hosts) The 1st prints contents line by line, while the 2nd prints contents as a whole in ...
4
votes
2answers
55 views

How to kill a bunch of jobs based on ps output?

Here is output from ps: $ ps aux | grep blob ubuntu 4286 0.0 0.1 34748 9592 ? S Jan14 0:00 /usr/bin/python /usr/local/bin/pynt start_blob_reader ubuntu 4287 0.0 0.1 34748 ...
2
votes
2answers
44 views

Does zsh expansion work differently in non-interactive scripts?

I'm currently working on a pretty simple zsh script. What I often do is something like: mv */*.{a,b} . When I run that within a zsh script, it seems to expand differently and fail while it works in ...
0
votes
3answers
46 views

read command in zsh throws error

In zsh, running the command read -p 'erasing all directories (y/n) ?' ans, throws the error, read: -p: no coprocess But in bash, it prints a prompt. How do I do this in zsh?
2
votes
1answer
20 views

Vim and unified diffs

In my daily work, I only deal with unified diffs, so I would like to define the alias alias diff='diff -puN' in my .zshrc. This alias is not respected when I use the shell from the vim command ...
18
votes
1answer
297 views

Why does exporting vim as EDITOR in zsh disable keyboard shortcuts?

My .zshrc looks like this: export EDITOR="/usr/bin/vim" Now when I open a terminal and enter a keyboard shortcut like ctrla to go to the beginning of the line, it doesn't work. Instead, the string ...
2
votes
1answer
35 views

zsh case-insensitive mid-word completion

I have the following in my .zshrc for case-insensitive tab completion. I encountered a situation where the tab completion fails, and I can't figure out why. autoload -U compinit && compinit ...
4
votes
3answers
488 views

Echo command with AND operator doesn't exit

echo hai && echo bye prints hai bye while echo hai && echo $? prints hai 0 When the first echo command's return value is 0, how does the echo statement after AND operator ...
-2
votes
2answers
59 views

autocomplete weirdness as a result of ugly hack for zsh prompt

I currently have the following line in my .zshrc: export PROMPT=$(printf "\e[38;5;6m")%m$(printf "\e[m")%d-%h:" " Which is supposed to show the hostname in blue and history and current working ...
2
votes
2answers
111 views

zsh keeps forgetting PATH vars

I'm using [oh-my-zsh] in iTerm on MacBook running Mavericks. I have iTerm set to source my .zsh file on load, and mostly that works. cd && source .zsh Except when it doesn't. Sometimes, ...
3
votes
1answer
37 views

Shell glob - substitute file path arg with file's contents

In curl command, there is --data option, which substitutes the file contents when the option value is prefixed by @ symbol like, curl -X POST --data @abc.json hostaddr.com abc.json file contents ...
1
vote
3answers
131 views

Bash long string, no word splitting?

I want to tidy up some script with long commands, so that for example: { somecheck || somecomand "reallyreallyreallyreallyreallyreallylongstring" } &> /dev/null & becomes something like: ...
0
votes
1answer
39 views

zsh parse error after alias do=…

I have the following .zshrc file in my home directory: # modify the prompt to contain git branch name if applicable git_prompt_info() { current_branch=$(git current-branch 2> /dev/null) if [[ ...
2
votes
1answer
37 views

How can I use !! in zsh alias

I am trying to create an alias that builds upon my previous command. Say I run ag foo After looking at the list I want to be able to use those results in vim so I do vim -q<(!! --vimgrep) The ...
4
votes
0answers
44 views

How to make zsh correct remember my decision

I have enabled correction (I wouldn't call it autocorrection specifically because of this issue) in zsh by enabling setopt correct in my .zshrc. Now, when I type dtae in a terminal, I get: dtae ...
0
votes
1answer
55 views

What does $'text' do exactly in Bash? Can it be used in Zsh?

I recently run into the following proposed solution: cat results.csv | tr $'\x01' \\t > result.csv to convert a malformed csv file (one that uses \x01 unicode as a separator) into a correct one. ...
1
vote
0answers
53 views

Making zsh filename completion case-insensitive everywhere

I have the following line in my zshrc to make filename completions case-insensitive: zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' This works most of the time but I’ve noticed that if I ...
3
votes
3answers
56 views

Is there a nice way to set directory/project local environment variables?

I have been working on several projects, and they require different environment variables (e.g., PATH for different versions of clang executables, PYTHONPATH for several external modules). Whenever I ...
4
votes
2answers
62 views

Coming back to a command I have partially written [duplicate]

Often I find myself partway through writing a long command (or chain of commands) and realise I need to run another command before I can finish typing out this current one. Examples Sometimes, I... ...
2
votes
1answer
248 views

alias -g '${1+“$@”}'='“$@”', what does it do?

Most makefile have this strange set of symbols '${1+"$@"}'. $@ is the makefile target filename. But why does, people try to use the complex symbol like '${1+"$@"}'?
8
votes
1answer
134 views

Why does brace expansion range use two dots instead of three (ellipsis)?

I finally understood/discovered why I never got to using bash's (and also zsh's) brace expansion range properly: the syntax is {1..10} instead of what I assumed to be an ellipsis, i.e. {1...10}. May ...
4
votes
5answers
170 views

How can I use a wildcard to match just files, not directories?

I have a folder called home/homeLife I have a file called home1 home2 and home3 stored in /home I want to move all files that start with home* to home/homeLife/.. I typed mv home* /home/homeLife ...
3
votes
1answer
46 views

Zsh gpg2 autocompletion

I am using zsh with oh-my-zsh on OSX. I installed gnupg2 from homebrew giving me the executable gpg2. Unfortunately zsh auto completion appears to only support gpg (even though that executable is not ...
1
vote
1answer
53 views

zsh git command auto-complete add extra origin to the git branch name

After I clone a git repository locally, I want to switch branch to, says, 'ABCD'. $ git branch -a * master remotes/origin/ABCD remotes/origin/HEAD -> origin/master remotes/origin/master $ ...
1
vote
0answers
18 views

Is there a better to find out the script location which is part of a zprezto module?

I am writing a custom module to extend the zprezto framework for myself. The goal is to be able to start a tmux with proper configuration by name. Here is the code of the init.zsh of my custom module: ...
3
votes
1answer
96 views

Combining zsh’s tab completion with case insensitivity

I have zsh 5.0.7 configured to use case-insensitive tab completion with zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' The problem I’m having is that this case insensitivity often leads ...
0
votes
1answer
89 views

How to turn on tab completion in zsh/prezto?

I have installed prezto and trying out zsh. However tab completion is not on by default. What is the best way to enable tab completion in prezto?
2
votes
0answers
32 views

Why does select-word-style stop me from using backward-kill-word for leading whitespace?

If I have just some whitespace at be beginning of my zsh prompt, I can usually ^W (backward-kill-word) it away. However, as soon as I load select-word-style - even if I don't select any special style ...
3
votes
1answer
109 views

Why is `setopt nohup` required to make `nohup watch` work in zsh?

In zsh, setopt nohup seems to be required to make nohup work, as follows: # nohup does not work without setopt nohup ➜ /tmp zsh ➜ /tmp nohup watch ls & [1] 31556 nohup: ignoring input and ...
0
votes
1answer
28 views

Is there a valid way of exporting a variable across different shells?

For some reasons, Im using ksh and zsh in my scripts and returning to -bash, I need to use already set variable values in the spawned shells, writing it to some temp file and using that didn't look ...
1
vote
0answers
43 views

How can I complete a -N numeric parameter?

I'm writing an autocomplete script for supervisorctl. Is it possible to complete a numeric parameter such as -6, -999 etc? Currently my call to _arguments looks like, which doesn't work: _arguments ...
1
vote
1answer
77 views

Ctrl-Arrow does not work anymore after installing Prezto

I have this in my .inputrc: "\e[A": history-search-backward "\e[B": history-search-forward set show-all-if-ambiguous on set completion-ignore-case on # mappings for Ctrl-left-arrow and ...
3
votes
1answer
76 views

Filename expansion from date ranges

Consider dates in the ISO 8601 format i.e. ‘YYYY-MM-DD’, e.g. 2015-01-28, and say we have a folder with files of the form: AAAA_<date>_BBBB I am looking for a glob pattern in zsh (or Bash) ...
2
votes
1answer
85 views

terminal converts first letter to uppercase

After a $ vagrant ssh into a Centos 7 VM, - If I type a command in the VM terminal that uses zsh shell, the first letter gets uppercased. How can I stop this behaviour? I briefly looked at $ stty ...
2
votes
1answer
89 views

Multi-month view in calendar (cal) in OS X

I am hoping to run some of the commands listed in this article, e.g.: cal -3 which is supposed to show me the last month, this month, and next month. This command does not work in OS X. $ cal -3 ...
2
votes
2answers
113 views

Export Command History into a Shell Script

Often I have complicated installation procedures to follow, like having to build dependencies for buildtools, to build dependencies for the application I wish to install from source. Once I have done ...
1
vote
2answers
58 views

Why does zsh allow name to be null in ${name:-word}?

From zsh documentation: ${name-word} ${name:-word} If name is set, or in the second form is non-null, then substitute its value; otherwise substitute word. In the second form name may ...
1
vote
2answers
69 views

ls .. doesn't work properly with symlinks

I have directories set up a bit like this ~/code ~/code/src ~/code/build -> /path/to/somewhere/else That last one's a symlink. If I do this cd ~/code/build ls .. then I get the listing for ...
1
vote
1answer
94 views

Every time I run tmux, new ssh-agent child process is started (zshell)

Every time I start tmux or split tmux, new instance of ssh-agent is started ("Agent pid XXXX" appears on the top), which is quite annoying because I have to type the key password every time I want to ...