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

learn more… | top users | synonyms (1)

1
vote
0answers
34 views

Issue in activating environment on UAT server

I was working on a script that logs in to UAT server, reroute to necessary folder and activates the virtual environment. Following is the script: function gotouat(){ branch=`getBranchName`; ...
7
votes
3answers
536 views

Per-directory history in zsh

I am happily using zsh since a while now, and I am quite satisfied with my history settings, which are: # Write to history immediately setopt inc_append_history # History shared among terminals ...
1
vote
1answer
69 views

Execute a command in zsh vim mode

In zsh in vim mode, I write something foo foo bar bar Then I hit Esc to go in normal mode and type : foo foo bar bar execute: _ Then, I assume I can do that, I want to search and replace bar ...
3
votes
3answers
54 views

All files in a directory that do not end in a specific string?

I want to find all text files in a directory that do not end with the string: hello world How can I do this?
0
votes
1answer
49 views

PATH not getting exported from ~/.profile until manually sourced

I am trying to modify my PATH in ~/.profile: export PATH=$PATH:/opt/jdk1.8/bin echo "Path is exported." I will always login via SSH so that's why I have it in ~/.profile. I am using zsh (oh-my-zsh) ...
1
vote
2answers
169 views

Specifying numeric ranges in zsh history

According to the docs I can tell the zsh history to print lines in a range. The docs say "history [first [last]]" I've tried "history a b" but that gives a too many arguments error. I've also tried ...
2
votes
2answers
48 views

Prompt: replace custom path with a short word like ~ for home

When I call cd /Users/mu3/apps the prompt simplifies it like this: mu3 [~/apps]: Is this possible to do the same for custom path like cd /Users/mu3/Development/Web/test: mu3 [DEV/test]: I'm ...
2
votes
2answers
52 views

How to store the printout of the last command in a shell variable in urxvt/zsh?

I'd like to have the printout (stdout and stderr) of the last command run within zsh available in a variable ready to use grep, etc on it.
0
votes
1answer
36 views

How to find latest file and delete old files in a group of files in zsh scripting? [duplicate]

I am facing problem in zsh scripting. I have group of files in a directory such as: 001_20160223.txt /delete 001_20161102.txt /delete 001_20161209.txt /keep 005_20160502.txt /delete ...
0
votes
1answer
54 views

ZSH, concatenate passed in arguments into a single string

I would like to create a simple bash function to use for my convenience. Following the answer given at: Joining bash arguments into single string with spaces I've been able to mash up this small piece ...
1
vote
0answers
25 views

How to have full completion in a run application dialog?

I've configured XFCE to execute gmrun as run dialog (Alt-F2). It works great with completion on commands but does not propose completion on arguments. How to set up a run dialog with full bash/zsh ...
2
votes
0answers
52 views

zsh theme doesn't work on a remote server [closed]

Here is a screenshot from the author of a theme: And this is what I have: What am I doing wrong?
2
votes
1answer
101 views

pushd, popd vs cd, cd- in bash and zsh

Is there a difference between the behavior of pushd/popd in bash vs zsh? It seems in zsh cd, cd- behaves exactly the same as pushd/popd (which adds/pops directory automatically when cd) while in bash ...
1
vote
3answers
88 views

Unlimited history in zsh

In zsh, I want to have unlimited history. I set HISTSIZE=, which works in bash. Now I import an old history mv old_history .history which is pretty big wc -l .history 43562 .history If I now ...
29
votes
2answers
9k views

How do I perform a reverse history search in ZSH's vi-mode?

I use vim for essentially all my editing needs, so I decided to once again try vi-mode for my shell (currently ZSH w/ oh-my-zsh on OS X), but I find myself trying (and failing) to use Ctrl-R ...
1
vote
2answers
34 views

How to configure .zshrc for specfic os

I want to use emacs from Applications folder when I'm using Mac, but I'm using same .zshrc in Ubuntu. alias emacs='/Applications/Emacs.app/Contents/MacOS/bin/emacsclient' So I want to create this ...
3
votes
2answers
57 views

Remapping Ctrl-P to Ctrl-O for getting the previous command?

I am using zsh with tmux and I like to have Ctrl-P as a shortcut to 'previous pane'. I would however still keep the original 'previous command' functionality of Ctrl-P and map it to Ctrl-O. How can I ...
3
votes
4answers
156 views

Shorten path in zsh prompt

Bash has the PROMPT_DIRTRIM option, e.g. when I set PROMPT_DIRTRIM=3, then a long path like: user@computer: /this/is/some/silly/path would show instead as: user@computer: .../some/silly/path ...
2
votes
1answer
24 views

Change color when changing directory

I have two folders called Documents and Downloads. In zsh, when I type cdSpaceDoTabc the color of Documents change from white to (hard to read) gray. How can I turn off this color change or control ...
0
votes
2answers
52 views

How to get absolute path of current shell in a sourced script? [duplicate]

Suppose one executes either . some_script or source some_script How can some_script determine the absolute path of the current shell (i.e. the one that is executing the . or source command)? ...
1
vote
2answers
19 views

zle read first word in line?

Let us say: % ls ./ _ when foo is called, where _ is the cursor position. foo(){ echo $COMMAND } zle -N foo How can COMMAND be set such that foo will write out the 'command' (as in, the ...
2
votes
2answers
57 views

Updating shell functions and aliases through environment variables

Say we define the following shell function and alias in .zshenv: export VARIABLE_A='original' function my_function() { print $VARIABLE_A } export VARIABLE_B='original' alias my_alias="print ...
4
votes
1answer
64 views

Automatically open text files in editor instead of attempting to run them?

When I accidentally type the name of a text file without some kind of editor command, and the text file is not a shell script, I get a "permission denied" error*, since the file is not executable, and ...
1
vote
2answers
55 views

Is it possible to declare a local variable without overriding the original for the child processes?

If I have a pre-existing ENV variable, is it possible to declare a new local variable with the child process using the original value? Keep in mind, I don't know which variables the child process ...
1
vote
2answers
45 views

executable wrapper, run original executable from tail of PATH

There's an executable /usr/bin/foo which I and other scripts use but it misbehaves a bit so I made a Bash wrapper of the same filename in /usr/local/bin/foo where I fixed its misbehaviour. My PATH is ...
0
votes
1answer
35 views

linux - setting order in which files are read or output with utilities (sorting)

I'm having issues with programs reading files in the wrong order, and also outputting in an undesirable order with utilities such as ls. I've tried some of the LC_COLLATE options, but none of them ...
2
votes
3answers
1k views

Tmux Terminfo problem with Zsh key bindings

Zsh in Emacs edit mode comes with the default key binding ALT + Backspace to delete a word on the right side of the cursor and ALT + D to delete a word on the left side. I would like to add the latter ...
0
votes
1answer
39 views

.zshenv not sourced on ssh login?

According to the docs .zshenv is sourced on all invocations of the shell, unless the -f option is set. It should contain commands to set the command search path, plus other important environment ...
3
votes
4answers
109 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 ...
0
votes
0answers
59 views

Command not found, only when used in a script

I installed pup on my mac using homebrew. When I try this command in my terminal cat index.html | pup -p 'div[class="quote"] text{}' >> quotes.txt it works fine but when I use it in a ...
3
votes
2answers
51 views

On applying commands to groups of lines from stdin

The Unix package datamash supports the application of several summarizing operations to groups of input lines. For example1, here datamash is used to compute the sums of column 2 for each value in ...
8
votes
1answer
838 views

Why doesn't the process substitution <() work with ssh -F

I have some vagrant virtual machines. To log into them I issue the vagrant ssh command. I want to log into them using regular ssh command. The vagrant ssh-config outputs the suitable config file $ ...
0
votes
1answer
32 views

Why is cd appending dirs like pushd?

I am using zsh in Babun (Cygwin with oh-my-zsh and some extras). I noticed some odd behavior, it looks like cd is behaving like pushd? { ~ } » mkdir foo { ~ } » pushd foo ~/foo ~ { foo } » popd ~ ...
0
votes
1answer
15 views

How can I get a variables datatype in zsh?

For example zsh uses the variable $fpath to define include directories. How can I tell what type of variable $fpath is? i.e. is fpath a string number numeric array associative array
3
votes
1answer
41 views

zsh: Tab completion for function with Git commands

In zsh I am using the following function to delete a local and a remote branch with one command: gpDo () { git branch -d "$1" && git push --delete origin "$1" } Currently, ...
0
votes
2answers
45 views

Range arrays with custom step-size in Bourne shells

Say I want to create a range array of integers in a shell such that the array: Starts in $START_VALUE Ends in $END_VALUE Elements are $STEP_SIZE apart, starting from $START_VALUE. For anyone ...
0
votes
1answer
22 views

How to increase history in oh-my-zsh?

I just installed oh-my-zsh for the first time. I just want to know how can I modify the number of past commands that are remembered in history? Where can I set this setting?
6
votes
5answers
3k views

Getting relative links between two paths

Say I have two paths: <source_path> and <target_path>. I would like my shell (zsh) to automatically find out if there is a way to represent <target_path> from <source_path> as ...
10
votes
3answers
3k views

Pasting from clipboard to vi-enabled zsh or bash shell

I'd like to be able to paste from the system clipboard (or text selection) into my "vi-like" shell prompt using the keyboard. I normally use zsh and sometimes bash. In both cases, I have the shell set ...
3
votes
1answer
56 views

On passing arguments to programs through array variables

NB: though the question below features rsync, it is not a question about rsync; it is a question about zsh arrays. If I initialize the variable EXCLUDES like this EXCLUDES=( --exclude=/foo ...
2
votes
1answer
33 views

Possible redirection bug in zsh 5x

[This post's title needs some work; suggestions welcome.] The following command produces different outputs in zsh v. 4.x and 5.x: { ( printf "X\nY\n" printf "WARNING: foo\nWARNING: ...
1
vote
1answer
28 views

How can I configure zsh completion to launch a menu - for command options?

If I am cd'ing into a directory, there is a setting in my ~/.zshrc that tells zsh to always launch a menu when I hit tab on an ambiguous completion, e.g. ~% cd /etc/a tab will immediately cause a ...
1
vote
1answer
78 views

zsh HISTFILE - still read from ~/.zsh_history

I set my $HISTFILE env var to something custom, and my zsh is indeed writing to the new histfile. But when using up-arrow or other history-searching capabilities, it still reads from ~/.zsh_history. ...
3
votes
1answer
37 views

How to split a string on a control character?

I know how to split a string on a printable separator character; e.g. if the separator is ,: FOO='x,y,z' printf "%s\n" ${(s:,:)FOO} x y z But what if the separator is a control character, such as ...
5
votes
3answers
180 views

Why zsh and ksh93 chose to be non-compliant in pattern matching?

POSIX documentation for pattern matching said that: An ordinary character is a pattern that shall match itself. It can be any character in the supported character set except for NUL, those ...
3
votes
2answers
25 views

How do I set the editor command to use *only* for edit-command-line in zsh?

When I hit Ctrl+x, Ctrl+e in zsh, I can edit the current command line in by $EDITOR or $VISUAL. However, I'd like to use nano, and to get syntax highlighting for shell syntax there, I have to pass -Y ...
0
votes
1answer
25 views

Zsh's standard completion works fine, so why do people recommend to load compinit module?

If I put these lines and nothing else in my ~/.zshrc I get all the completion features I expected. # For autocompletion with an arrow-key driven interface zstyle ':completion:*' menu select # ...
3
votes
0answers
47 views

Calling zsh completion function and obtaining its results

I'm trying to make use of zsh's completion widgets in my own scripts. At one point I'd like have access to the result of every completion that is active in zsh, or rather I want to obtain the final ...
1
vote
0answers
24 views

highlighting of zsh correction

When zsh's autocorrection suggests a change in long filename, it may be hard to spot which change is actually suggested: The example is of cause artificial as tab completion would've done the job ...
9
votes
4answers
37k views

Change font in echo command

Is it possible to change the font attributes of the output of echo in either zsh or bash? What I would like is something akin to: echo -n "This is the font: normal " echo -n $font=italic "italic," ...