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

learn more… | top users | synonyms (1)

0
votes
1answer
17 views

watch equivalent in zsh

In bash, watch (e.g. watch -n 5 ls -l) could be used to repeat the command at fixed intervals. This command seem to be missing on zsh. Is there an equivalent?
0
votes
1answer
20 views

Execute a function before specific programs

This began with the want of adding SSH keys to ssh-agend on demand, but because this isn't possible with OpenSSH, I came up with this zsh script instead. But for a reason I can't figure out, instead ...
3
votes
1answer
27 views

(2x) zsh: command not found

I've finally decided to take the plunge and try out zsh...Running on a CentOS 7 machine. The only thing I find strangely aggravating is that for some reason each time I enter an unknown command, I get ...
1
vote
1answer
18 views

How can I get zsh's completion working in the middle of the filename?

This works Normally, zsh's tab completion works well. $ touch foo-1-bar foo-2-bar $ touch f<Tab> $ touch foo--bar ^ cursor here Pressing Tab again brings up a menu from which I ...
3
votes
1answer
68 views

Append (alter) each array element via parameter expansion (i.e. without printf)?

Let the script below exemplify my quandary.. #!/bin/zsh STUFF=( moose-hoof ovary clydsedale ) echo ${MINE=$(printf "MY-%s " $STUFF)} echo ${MINE_EXP=${STUFF/^/MY-}} MY-moose-hoof MY-ovary ...
3
votes
1answer
31 views

Move to the previous line of a multi-line command

When editing multi-line commands, with escaped newlines, I cannot move up lines. For example, suppose I enter echo \ one one line, then I press Enter, and then I want to edit the echo \ part of the ...
1
vote
0answers
16 views

Can I prevent zsh slowing with a large history?

I've just migrated from bash to zsh. I converted ~/.bash_history for use in zsh. It's 150 000 lines long. bash is almost instantaneous to start up, but zsh is now fairly slow, taking half a second to ...
0
votes
0answers
28 views

How can get the screen command to work properly?

I'm trying to work out how to use the Unix screen command. I'm using Zsh on Mac OS 10.11.3. So far, nothing is working as described. (I don't have enough reputation to link to the tutorial I'm ...
0
votes
1answer
19 views

How can I delete to a slash or a word in zsh?

Bash behaviour I've just migrated from bash to zsh. In bash, I had the following line in ~/.inputrc. "\e\C-?": unix-filename-rubout Hence, Alt+Backspace would delete back to the previous slash, ...
1
vote
1answer
29 views

copy&paste in zsh

I've build myself this little script for zsh, to copy & paste within zsh to the system clipboard (basically got everything from here: zsh copy and paste like emacs) x-yank() { zle ...
4
votes
1answer
342 views

How to trigger a 2nd command when a specific command is run in the shell?

I'll explain my question with example. I run $ python manage.py to perform some action. I want to run another command $ xyz , just when any user runs the previous command. Thus, from now on, ...
1
vote
1answer
9 views

zsh jump to the end of copy from X clipboard

I would like to get Ctrl + V and Ctrl + X to paste / copy from zsh to X11. I found the following snippet to work but zsh does not jump to the character after paste. How could I do that. ...
3
votes
0answers
28 views

No zsh-syntax-highlighting within tmux

I experience proper zsh-syntax-highlighting (see here) when first opening a shell session, but as soon as I enter tmux, the syntax highlighting no longer appears. I found this Github issue ...
3
votes
1answer
26 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
67 views

Sticky entries in shell history

Is there a way one could make some commands "sticky" in a shell history? I want to save some favourite commands that would be searchable with Ctrl+R, like the rest of the history, but they should ...
1
vote
1answer
25 views

How to programatically send break signal (Magic SysRq) through serial terminal

I have following setup - I have 2 computers connected by serial connection (null modem) emulating vt220. I'd like to send break signal (Magic SysRq) from shell script - is it possible without writing ...
1
vote
0answers
14 views

tmux start process if not already running

In my .zshrc, I have a bit of logic that will automatically start a tmux session or, if sessions are already running, prompt to attach to one of them or create a new one and attach to that. This all ...
0
votes
2answers
16 views

Looking for a (preferably “all-zsh”) alternative to printenv that can handle Unicode in variable names

zsh supports variable names with Unicode characters (if the multibyte option is set), but printenv (at least GNU's version 8.23 thereof) doesn't seem to be able to handle such variable names. For ...
0
votes
1answer
14 views

Why don't subshell expressions in ~/.zshenv lead to infinite regress?

I understand that ~/.zshenv gets sourced every time that an instance of zsh starts. This implies that having the following line ~/.zshenv would result in an infinite regress: (echo "$$ $(date)" ...
5
votes
4answers
612 views

Why does `==` behave differently inside `[ … ]` in zsh and bash?

I get what I expected when doing this in bash: [ "a" == "a" ] && echo yes It gave me yes. But when I do this in zsh, I get the following: zsh: = not found Why does the same command ...
3
votes
1answer
31 views

Looking for a map of the xinit/startx rabbithole

Can someone point me to an authoritative guide to the X11 initialization sequence that also explains how it dovetails with the shell's initialization? I'm trying to figure out how to make some ...
3
votes
0answers
23 views

How do I write a custom filename completer for specific directories in zsh?

I've found that file names with dates before the title are difficult to tab-completion. I'd like to write custom completion functions for these directories. How do I specify that the completer should ...
10
votes
3answers
607 views

How to implement “generators” like $RANDOM?

The special variable $RANDOM has a new value every time it's accessed. In this respect, it is reminiscent of the "generator" objects found in some languages. Is there a way to implement something ...
0
votes
1answer
18 views

bash-like last command in history using up-down arrow keys in zsh [duplicate]

In bash, we can use the up and down arrow keys to get the last or nth previous command in history. Can we do this in zsh?
0
votes
0answers
8 views

bash one-liner for opening `less` on the last screen w/o temporary files [migrated]

I try to create o one-liner for opening less on the last screen of an multi-screen output coming from standard input. The reason for this is that I am working on a program that produces a long AST and ...
4
votes
2answers
43 views

How can I kill my backticked yes process?

I was playing around in my terminal, which runs zsh. I typed the following: $ ` bquote> yes bquote> ` And then, yes started to run in the background, I think. Neither Ctrl + C nor Ctrl + \ ...
1
vote
1answer
17 views

Can I auto-complete by tab in zsh with regular expression

I use oh-my-zsh configuration. When I want to auto-complete, I need to first type correctly the initial letter. For example go, then tab will give google-chrome. If I type *le-ch*. It didn't work. How ...
3
votes
1answer
16 views

command-click git commit ID in Terminal, and be taken to that commit in github?

I'm running a Mac and use iTerm with ZSH as my shell. Currently I can command-click (⌘+click) on links or directories in my iTerm window, and that directory or web link will open. Is there a way ...
-3
votes
1answer
56 views

Works in Bash but not ZSH? … alias ls='ls -lh' [closed]

alias ls='ls -lh' Previously used this in bash to achieve default ls arguments Trying to move to ZSH but have discovered this trick does not work. Is there a preferred way to do this in ZSH? ...
0
votes
0answers
8 views

Why is zsh seemingly ignoring no_list_beep?

I have zsh (5.1.1) on OS X (10.10.4), and am using oh-my-zsh with various plugins. When I type e.g. ls z in a directory with multiple items starting with z, zsh beeps and then displays an ...
3
votes
0answers
44 views

Suspend a process silently with ctrl-z

With my current workflow, I frequently use CTRL-z to suspend Vim so I can enter a quick few commands before resuming editing my code with fg (actually, it's CTRL-z again, thanks to the handy ZSH tip ...
11
votes
2answers
588 views

Is there a reason why the first element of a Zsh array is indexed by 1 instead of 0?

From my experience with modern programming and scripting languages, I believe most programmers are generally accustomed to referring to the first element of an array by 0 as index. Are there any ...
1
vote
1answer
16 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 ...
2
votes
1answer
36 views

Cancel an option used in aliased command?

Suppose for example, the following implementation of ll: alias ls="ls -F -G" # colourise and display dir,exec,etc. icons alias ll="ls -l -h -o" # long-list, use KB,MB,etc. sizes, no ...
1
vote
1answer
20 views

Why are some ZLE sequences being remapped to “self-insert”?

I've been tinkering with my dotfiles lately, and at some point I lost use of the default ^A and ^K keymappings, which I use frequently. bindkey -L | grep '\^[AK] # bindkey -R "^A"-"^C" self-insert # ...
0
votes
1answer
30 views

What's the equivalent wildcard operator in Zsh to Bash's *

I have just started using Zsh and I have noticed that the asterisk (*) wildcard operator does not seem to work in it. For example, running cd ~/Doc* does not change me into the ~/Documents directory ...
3
votes
1answer
68 views

Shell function to check if there is a suspended process that's a child of this shell?

I'd like to add an indicator to my PS1, showing whether there is a process suspended with ctrl+z. In order to do so, I'll need a function that is able to check for this situation. I'm not even sure ...
0
votes
0answers
26 views

Set a ZSH shell variable using mintty?

I have configuration files that I use to make my PS1 fancy. The design depends on the presence of a particular font. If the font isn't present, the PS1 looks ugly. I share access to a webmaster ssh ...
1
vote
1answer
21 views

zsh-newuser-install not working

I recently started using zsh as my default shell on my Fedora system. Today I installed a fresh CentOS 6.7 system and changed the shell after installing zsh on it for userx using: [tu3@TestC001 ~]$ ...
3
votes
1answer
37 views

How to configure Ctrl+w as delete word in zsh

I want to delete a word by Ctrl+W in zsh like. vim /foo/bar^W vim /foo/ And found a solution for bash, but bind is not in zsh function. Is it possible to configure ctrl-w (delete word)? How can I ...
4
votes
1answer
57 views

Zsh prompt filling whole width with user input in next line

I'd like to have the left and right prompt in one line and a background color spanning the full line. The user input should be in the next line. hostname | ~/path/to/cwd ...
1
vote
1answer
28 views

What's the intended use case for COMPLETE_ALIASES in zsh?

For some months now, I have had setopt completealiases in my .zshrc. I haven't the faintest idea why I added it - most other things have comments or can be understood from neighbouring settings. ...
2
votes
1answer
19 views

Get full path of current zsh startup file (e.g. zshrc or zshenv)

Is there a way to get the full path of the current zsh startup file being processed (e.g. zshrc or zshenv)? In other words, imagine I have a zshrc file that can either be located at ...
0
votes
1answer
36 views

Zsh theme not being applied [closed]

I want to use zsh and the hassle starts already with setting the theme. I have .oh-my-zsh on my ~ I have a .zshrc file with the following line: ZSH_THEME="3den" I changed my standard-shell to zsh ...
1
vote
1answer
39 views

How to declare some aliases dynamically in zsh?

I would like to declare a few shortcut commands to switch between my various coding projects, so I have come up with the following script. projects=$(ls -d ~/Workspace/*/) ...
5
votes
2answers
189 views

What is causing `diff` to run `git diff`?

I'd like to use diff as described here and in the documentation I see when I type man diff. However, when I type diff, what I get is this: ~ ❯❯❯ diff usage: git diff --no-index <path> ...
1
vote
1answer
28 views

strange setopt behavior

For certain options, setopt doesn't have an effect. ➜ ~ setopt | grep history extendedhistory ➜ ~ setopt appendhistory ➜ ~ setopt | grep history # appendhistory apparently didn't get set ...
2
votes
1answer
41 views

How to create an alias for two Git commands that use a parameter? [duplicate]

I regularly have to delete a local and remote Git branch. Therefore, I run the following commands: $ git branch -d feature-branch $ git push --delete origin feature-branch Since I mostly execute ...
4
votes
1answer
74 views

How to create string with invalid unicode characters, in Zsh?

For some testing purposes I need a string with invalid unicode characters. How to create such string in Zsh?
3
votes
3answers
167 views

Repeating command with different filenames

Here's a layup for someone... I'm having to run a command repeatedly: $ wp input csv MyCSV01.csv directory_name $ wp input csv MyCSV02.csv directory_name $ wp input csv MyCSV03.csv directory_name ...