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

learn more… | top users | synonyms (1)

0
votes
0answers
7 views

How can I programmatically access zsh completion?

zsh has a completion system, activated by pressing tab: llama@llama:~$ git st<Tab> Completing main porcelain command stash -- stash away changes to dirty working directory status -- ...
1
vote
0answers
9 views

How did I get the git commits to show up in autocomplete?

Git tab completion on my mac: Git tab completion on my Ubuntu server: On my mac and my Ubuntu server I get very different output from tab completion despite having the same version of zsh, same ...
7
votes
0answers
118 views

How to make the zsh “correct” functionality, remember my spell-correction decisions

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
0answers
50 views

Run console printing command after tmux starts up

I'm starting tmux from zsh with the window split into two panels. The only issue I'm having is screenfetch starts up and prints to both windows. Ideally I only want it printing on the left window. I ...
9
votes
4answers
38k 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," ...
4
votes
2answers
548 views

How change prompt of subshell

I'm trying to create a simple script that, among other things, will create a subshell: #!/bin/sh # setup "${@:-$SHELL}" # teardown The question is: I need to change the default prompt, so for ...
0
votes
0answers
45 views

How can get the screen command to work properly? [on hold]

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. If I type screen as directed, this is the result... I don't ...
1
vote
1answer
905 views

Colors not rendered correctly in oh-my-zsh themes

I'm trying to use colors in oh-my-zsh themes. It works fine on my home computer (ubuntu), but in a work computer (Scientific Linux i.e. Enterprise linux) the prompt colors are actually spelled out. ...
7
votes
4answers
125 views

How do I determine if a program is running when I start a shell and start that program if it is not already running?

When I start a shell, in my case bash and/or zsh, what lines do I need to add to .zshrc and/or .bashrc to check to see if a program is already running, and if the program is not already running, start ...
2
votes
1answer
27 views

Backspace in zsh stuck

In set -o vi mode in bash, when I press Esc+k to get the last entered command, and then A, I end up in the insert mode, which allows me to press backspace to start deleting the end of the last command....
1
vote
1answer
33 views

Printing all variables starting with foo in zsh

In bash: foo_a=1 foo_b=2 declare -p ${!foo_*} Outputs: declare -- foo_a="1" declare -- foo_b="2" How do I do this in zsh? Why won't pasting the above into zsh fail to even set the variables? ...
1
vote
1answer
31 views

Copying current command line to clipboard [duplicate]

In bash with set -o vi, I use bind '"\C-]":"\C-[A\C-u cb <<"EOF"\n\C-y\nEOF\n"' to make ^] in insert mode cat the current line to my clipboard wrapper (cb). How do I emulate this in zsh (...
1
vote
0answers
37 views

Can I change how zsh autocomplete works?

I love the zsh autocompletion for navigating in files with commands like cd, but some commands have weird autocompletion, for example: when i type snap ins, bash autocompletes that to snap install, ...
1
vote
1answer
28 views

binding key shortcuts to shell functions in zsh

In zsh, how do I bind a keyboard shortcut to a function? In other words, how do I translate: bash: hw(){ echo "hello world"; } bind -x '"\C-h": hw;' to zsh?
5
votes
1answer
452 views

Keyboard bindings from bash to zsh?

I have the following entries on my .inputrc for bash: "\C-p": history-search-backward "\C-n": history-search-forward "\e[A": history-search-backward "\e[B": history-search-forward "\e[C": forward-...
0
votes
0answers
21 views

tmux ctrl-k to erase the line from cursor to end of line

Outside tmux I use ctrl-k to erase the line in my terminal with zsh from the cursor to end of line. When I'm in tmux it doesn't work. Below is my tmux.conf: set-option -g prefix C-a # From: https://...
1
vote
1answer
22 views

How to change the key for autocompletion in ZSH?

I'm on Ubuntu Mate 16.04 using terminator as my terminal. And using ZSH version 5.1.1. I'd rather change the keybinding to the left arrow key to emulate fish in a way. Anyone know how?
37
votes
1answer
9k views

When is double-quoting necessary?

The old advice used to be to double-quote any expression involving a $VARIABLE, at least if one wanted it to be interpreted by the shell as one single item, otherwise, any spaces in the content of $...
1
vote
1answer
22 views

New keybindings in ZSH are not saved

I just switched from bash to zsh on my arch linux install and want to change my keybinding so that ctrl + arrow skips a word forward/backward. If I add bindkey "^[[1;5C" forward-word bindkey "^[[1;5D"...
0
votes
0answers
22 views

How to map Ctrl-c to normal mode in zle?

In zsh with vi bindings, I want to leave insert mode not only using Esc but also using Ctrl-c. I tried this as suggested in another answer. bindkey -M viins '^C' vi-cmd-mode Pressing Ctrl-c still ...
9
votes
4answers
930 views

Why does cut fail with bash and not zsh?

I create a file with tab-delimited fields. echo foo$'\t'bar$'\t'baz$'\n'foo$'\t'bar$'\t'baz > input I have the following script named zsh.sh #!/usr/bin/env zsh while read line; do <<&...
3
votes
2answers
64 views

obtain shell prompt in python

I want to obtain the (zsh) shell prompt in a python script. Simply using import os prompt = os.environ['PS1'] seems not to be the right way, because PS1 is usually not forwarded to subprocesses. In ...
1
vote
0answers
27 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 (...
2
votes
0answers
25 views

custom zsh autocomplete

I'd like to write a zsh completion for pytest. Where do I Start? I'm using oh-my-zsh. in .zshrc: fpath=($HOME/.mycompletions $fpath) autoload -U compinit && compinit -u in $HOME/....
1
vote
1answer
14 views

zsh vi mode: browse recent commands starting with

I've recently switched to vi-mode in my zsh and there is a feature from emacs-mode that I cannot find how to do in vi-mode. The feature is browsing history by lines starting by something I've already ...
2
votes
1answer
20 views

how to have a custom zsh auto_cd command

Instead of the normal cd I've created my own function function cd { builtin cd "$@" && ls -F } This works great for when I use commands like cd someDir/subDir but not when I change ...
3
votes
1answer
34 views

Write warning while typing in zsh prompt

I know that it is possible to display text "outside" of the zsh prompt where you are typing. Common example is completions: myhost Wed 8 10:06 ~/sandlot $ e .py█ Press Tab, et voilá: myhost Wed 8 ...
2
votes
2answers
252 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 Ctrl-right-...
0
votes
1answer
34 views

Can't remove apostrophes from filenames in terminal [duplicate]

I don't understand why zsh and bash (ls) show me lots of filename inside apostrophes, but not all: 'joe rilla - mauern fallen.mp3' jokaz-alarmbereit.mp3 'yoshi blessed - everybody free.mp3' I tried ...
2
votes
1answer
42 views

Accessing random array element in ZSH

I have ZSH as my primary shell, and I'm trying to randomise access to an array. I keep seeing feh called, but I don't have that command. I have _feh, but I don't know if it's the same thing. What is ...
0
votes
0answers
49 views

zsh function: maximum nested function level reached

Consider this simple function I am trying to add in my .aliases (dnf is Fedoras newest replacement of Yum): function abc() { dnf search something } It works well on Bash but I get the following ...
3
votes
1answer
56 views

Run one command after another in zsh when Ctrl-C is pressed

I have recently moved to zsh from bash (on OSX). I have an bash alias I have used to run one program then another (even if previous program exits with error) on bash. I can't work out how to ...
3
votes
1answer
37 views

align rprompt with top of prompt

I've recently been getting really excited about zsh, and making myself an extravagant prompt, but I'm stuck trying to align my RPROMPT. I have an output like this: | [14:59:44] git:(master) ...
1
vote
1answer
38 views

Move files several directories up for several directories with similar layout

I have a directory with the following layout (the layout in Directory 1 is repeated in every other Directory <num>): Parent directory Directory 1 some directory another ...
3
votes
2answers
42 views

Looking for a convenient way to create a “constant array”

In zsh, is there a convenient way to create an array of n copies of the same integer? Context: In a shell script, I need to create an array, tile_lengths, consisting of two longish constant blocks. ...
1
vote
1answer
16 views

Alias folder of executables with prepended keyword

I have several executable files in a folder /opt/chefdk/embedded/bin/. Examples are ruby bundler chef. Ideally I want to be able to run these files by simply prepending the keyword chef-$1 or chef $...
1
vote
2answers
76 views

forward aliases to child process

I have some aliases which are defined in /etc/zprofile (or /etc/profile for bash). Also $PATH gets manipulated there. I want to start an interactive shell from a shell which avoids the $PATH ...
8
votes
4answers
7k views

Hybrid code in shell scripts. Sharing variables

This answer discusses how to run a multi-line Python snippet from the command line in a terminal. I noticed that the answer works great within shell scripts, even with nested indentation, which is ...
1
vote
3answers
40 views

How to remove a zsh keybinding if I don't know what it does?

How do I disable a keybinding if I don't know what it is or what it's triggering? I have my zsh key mode set to vi-mode, through bindkey -v. To do a history search, I press Esc to get to "command ...
15
votes
4answers
5k views

ZSH: search history on up and down keys?

Currently, I have the following in my .zshrc: bindkey '^[[A' up-line-or-search bindkey '^[[B' down-line-or-search However, this only seems to match the content of my current input before a space ...
1
vote
1answer
50 views

Shell Font Over SSH

I have a Linux machine (CentOS 7) in which I frequently SSH into from multiple devices. I have installed ZSH and Oh-my-zsh on the remote machine. I would like to install the following theme: https://...
2
votes
4answers
101 views

Copy files to new directory only if name of file is in an array

I'm not much of a zsh buff but I imagine this should be an easy layup for someone: I can bulk copy files from sourcedir to targetdir with the following: $ find sourcedir -type f -exec cp {} ...
4
votes
4answers
217 views

Prefer file types in command line

Often I have to annotate multiple pdf documents using xournal. If I start with a directory of "fresh" pdf files, I just open them all with xournal: for f in *pdf; do xournal $f&; done When I ...
5
votes
2answers
98 views

How can I use the output of a command without using the mouse?

Imagine you issued a find command and now you want to use one line of the resulting output as an argument. $ find .. fileA fileB $ vi <CURSOR> # now do what to achive: $ vi fileB ...
1
vote
0answers
16 views

zsh auto completion certain parts of directory

I currently have zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' which will ignore the case when auto completing directories. However is it possible to type a certain part of the directory and ...
2
votes
1answer
39 views

zsh tcsh-like history navigation

In tcsh, the \eP and \eN commands take into account the whitespace-normalized prefix of the current line, not just the first word. For instance if my history contains git pull upstream feature-...
0
votes
1answer
44 views

Zsh: hash directory completion

I have configured some directories alias via hash -d hashname=/path/to/directory command. Completion for that aliases works for a long time like this: % hashn<TAB> # becomes hashname, pressing &...
3
votes
2answers
74 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 ...
3
votes
2answers
38 views

Mark descriptor as terminal for the -t test

One can test if a descriptor is connected to terminal with -t test. if [ ! -t 0 ]; then echo "Stdin is not from terminal" fi Having a descriptor X, pointing to a file or to a process (with >(...
2
votes
1answer
30 views

How can I get a help message for zsh builtin's?

If I want to get a brief usage message for a bash builtin, I can use help <builtin> at a command prompt, e.g. $ help export export: export [-fn] [name[=value] ...] or export -p Set export ...