Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [zsh]

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

0
votes
0answers
10 views

Cant get virtualenv displayed in grml zsh prompt

I have some problems with configuring zsh grml shell. I coppied /etc/zshrc file to my home dir, and start using it. I noticed lack of virtualenv name while working with python. So I tried to run ...
1
vote
1answer
14 views

what is the zsh bindkey command for vim's dd?

i'm trying to remap dd to dl to match my .vimrc I read the docs for a good while, I couldn't find any command that matches the behavior of dd i.e deletes the line and goes to the line above, I tested ...
2
votes
1answer
15 views

count pattern matches in zsh array

I'm looking for something similar to the suggestion in this answer: Given a zsh array I want a count of how many elements match a pattern (rather than obtain the first/last match or the index of the ...
3
votes
1answer
62 views

$-expansions not performed as expected when following a redirection

It seems that bash and zsh will perform the variable and arithmetic expansions in a child process when a) they're following a redirection operator like <, >, >> or <<<. b) the ...
0
votes
0answers
8 views

How can I invoke a custom Zsh function compiled into a digest from a Makefile?

I have a custom Zsh function script compiled into a digest (.zwc) file and would like to invoke it from a Makefile after autoloading it. Is this possible?
1
vote
2answers
32 views

Read a line then append pound sign (#) at the start of it based on a condition

I have a bash script which reads a file having multiple line of text and executes a command on those lines. Sometimes the command work, but sometimes it fails. I want to append a pound sign (#) at the ...
1
vote
0answers
20 views

Tab complete global alias names not at the beginning of a line

I have a bunch of aliases like this alias -g foo=cmd1 alias -g faz=cmd2 alias -g fam=cmd3 At the shell (I'm using zsh) I want to be able to type echo fa<TAB> and be prompted for faz or fam ...
0
votes
1answer
26 views

Disable command name autocorrection

I would like to disable a feature. However Zsh is ignoring the settings I am inputting: > bind zsh: correct 'bind' to 'find' [nyae]? n zsh: command not found: bind > setopt nocorrectall > ...
0
votes
0answers
23 views

Zsh clear scrollback buffer

With Bash CtrlL will clear the screen but not scrollback buffer. In the past I have worked around this by using: tput reset However I have noticed that this command will not clear the scrollback ...
0
votes
0answers
34 views

Zsh disable autofill

Zsh disable autofill If I open a terminal and enter: echo 'hello world' after that if i press e it "suggests" the previous command. How can I disable this? I tried this with no success: autoload ...
2
votes
1answer
22 views

zsh scripting - How do I NOT match a pattern in filename generation?

I'm currently trying to loop through a set of directories, but only the ones I care about. $ ls -d */ cfdpost_statefiles/ p050L0260/ p050L0510/ p060L0390/ p070L0260/ p070L0510/ p092L0390/ ...
5
votes
2answers
33 views

Direct xtrace output elsewhere than stderr in zsh

In zsh, is it possible to direct the trace output from set -x (set -o xtrace) to a file descriptor other than stderr? I'm looking for an equivalent of $BASH_XTRACEFD or a way to emulate the same ...
1
vote
0answers
29 views

How to restrict autocomplete for the files found from PATH?

What I would like to be able to do is to have a list of words that are allowed to be autocompleted when typing the first word in the command line. Say, I have PATH=/dir, and the directory /dir has ...
0
votes
0answers
26 views

Tmux default directory is '/' the first time after reboot

When I start tmux the first time after a reboot, the default directory is '/' (also newly created tmux tabs have this default directory) and in the place of the tmux session number ('0' in the picture)...
1
vote
0answers
23 views

.zshrc configuration doesn't set ENABLE_TMUX to true

In my .zshrc, I have ENABLE_TMUX="TRUE" for one of the lines. This doesn't seem to work, as tmux never launches on a new shell, and the environment variable ENABLE_TMUX is always false when I start a ...
0
votes
1answer
46 views

How to use zsh tab completion on Git without origin?

I am using zsh with oh-my-zsh on Ubuntu 18.04.2. Currently, Git is installed at version 2.20.1. Whenever I want to push a local branch to a remote (origin) I try to use the tab completion in the ...
1
vote
1answer
49 views

make zsh run a command when no command is entered

Imagine I am typing at my terminal prompt, but actually decide not to type anything. Instead I just press enter. Is there a way I can make zsh run a command now? I want to potentially make this ...
3
votes
3answers
71 views

How do I open the current directory in a new tab?

My environment Terminal.app 2.9.4 on macOS zsh 5.7.1 When I used bash, Terminal could open current directory in a new tab, but it have not been able to do that since I changed to zsh. In the app ...
1
vote
1answer
27 views

Why in zsh setopt command and $- are not the same?

I am using zsh and if I type setopt it shows autocd nobeep extendedglob interactive login monitor shinstdin zle counts 8. while if I type echo $- it shows : 569BJXZilms counts 11. Why $- gives ...
1
vote
0answers
15 views

How do I enable listing of zsh commands as you type

on one of my machines while setting up zsh I seem to have accidentally enabled a pretty useful feature. when I search through command history it actually lists all the matching commands as I type. How ...
1
vote
1answer
32 views

Why does CTRL+U clear everything with zsh, not only the text before cursor, as expected

I've installed zsh and oh-my-zsh on my Mac terminal, then CTRL+U cut everything I input, no matter where the cursor is. If it's a common case, how can I set the CTRL+U to the original behavior?
0
votes
0answers
81 views

Which oh-my-zsh plugin is providing this tab-completion functionality?

I have the following zsh configuration: autoload -Uz promptinit promptinit HISTFILE=~/.histfile HISTSIZE=1000 SAVEHIST=1000 setopt appendhistory autocd extendedglob nomatch notify zstyle :...
2
votes
0answers
39 views

Small delay in sudo

I want my zsh prompt to display whether the session has sudo rights (from a previously run sudo command). After looking at the answers to this question, I arranged to use the exit status of sudo -n ...
3
votes
2answers
46 views

zsh completion for media player

In my .zshrc, I have menu select disabled globally, except for mpv/mplayer: zstyle ':completion:*' menu select=0 zstyle ':completion::complete:mpv:*' menu yes select This works as expected, but I ...
1
vote
0answers
21 views

can zsh autocomplete to its autosuggestion?

When I type ssh, it auto suggest to the last host I've ssh'd into. ssh <AUTOSUGGESTED HOST> Is there a way so that when I type "tab" it just autocompletes to the autosuggested option?
1
vote
2answers
113 views

How to key bind 'backward-kill-line' to Ctrl+Shift+Backspace?

I have used answer of zsh kill Ctrl + Backspace, Ctrl + Delete to configure following key binding: Ctrl+Backspace: delete until the beginning of current word, Ctrl+Delete: delete until the end of ...
2
votes
1answer
35 views

Grouping directories in `zsh`

Using zsh both of these command produce the same result: ls (dir1|dir2)/dir3/*.txt ls {dir1,dir2}/dir3/*.txt Using bash only the following works: ls {dir1,dir2}/dir3/*.txt So, if I want to list ...
2
votes
2answers
54 views

ZSH: How do I echo a program's output to a temp file if the output has newlines and other special chars?

I'm trying to write a ZSH script so I can run an arbitrary script (say, a JavaScript app) and open the script's output as a file in another application (my IDE). Here, my thinking is to invoke it ./...
2
votes
1answer
36 views

How to look up zsh completion definitions

Is there a way to lookup (just print the completion definition to stdout) currently loaded zsh completion functions. I understand that they are stored somewhere on my fpath and I could do something ...
3
votes
0answers
82 views

XFCE - Blank text in terminal

I've just performed a fresh install of Arch Linux on my laptop (ThinkPad A485, though that's probably not relevant here), and installed XFCE4. Everything seems to be working with the exception of one ...
1
vote
1answer
28 views

Conditional powerlevel9k prompt

I want to de-activate my right prompt when the tmux terminal pane gets small. Is there an easy way to conditionally render the RPROMPT variable based on screen width?
0
votes
0answers
22 views

zsh parse error: condition expected [duplicate]

getListing () { if [ "$1" = ""]; then alcListDir ~/Projects/Haskell/ -f \ | alcSortPath time | tac | xargs -n1 basename else alcListDir ~/Projects/Haskell/"$1"/ ...
0
votes
2answers
38 views

Script runs command fine, but fails when trying to save output to variable

I have a shell script with the following contents. I call it with ./script.sh. Echo successfully runs, but not when I try to save its output to a variable. The same is true for all commands I've ...
1
vote
1answer
16 views

arrow keys for line editing during zsh read builtin

I have a little zsh script for prompting the user for some input: #!/usr/bin/env zsh IFS="$(printf "\n\t")" printf "${1-query}: " 1>&2 read -r query echo "${query}" If I type something at the ...
0
votes
1answer
25 views

Konsole does not run shell specified in /etc/passwd

I've been using Bash for a long time on Fedora with Gnome, and recently switched to Arch Linux, Plasma and ZSH. I set up zsh, file, used chsh -s $(which zsh), and it works. However, every time I run ...
0
votes
1answer
48 views

ZSH (O-M-Z + powerlevel9k) + glyphs + console only (Ubuntu server edition): How to get all 3 working?

So I have installed ZSH + oh-my-zsh + powerlevel9k on my Ubuntu server edition. While it's working including the colors (I used darkorange background to display current user), I cannot get the glyphs ...
8
votes
2answers
97 views

Inverting an associative array

Let's say I have an associative array in bash, declare -A hash hash=( ["foo"]=aa ["bar"]=bb ["baz"]=aa ["quux"]=bb ["wibble"]=cc ["wobble"]=aa ) where both keys and values ...
1
vote
1answer
49 views

/bin/sh symbolic link not working properly

I am using i3, and by default, it uses sh when starting process with the i3 config exec command. This is fine and dandy, but that means the environmental variables created in my .zshrc do not get ...
16
votes
4answers
1k views

Running a subshell from the middle of the current command

I frequently find my self in this scenario. I'm in the middle of typing a command and I need to check something else before I complete it. Is there a way to open a subshell of some sort with my ...
1
vote
2answers
51 views

mv : get info from files to be overwritten

Is there any "super" mv command out there which displays files info (size, date, etc.) when a destination file is to be overwritten with a source one ? This is, when moving files around and two files ...
0
votes
0answers
12 views

Ubuntu multiple terminal shell configuration [duplicate]

How to allocate different shell to different terminal emulator? Ex : for terminator terminal allocate /bin/zsh shell and for gnome-terminal /bin/bash shell.
2
votes
3answers
52 views

Prepending some text to each element of an array

In zsh, with glob expansion we can use the P flag to prepend each match with some text: $ ls -1 bar baz foo $ print -- *(P:--file:) --file bar --file baz --file foo Is there something analogous for ...
0
votes
1answer
28 views

How do configure ZSH commands substition to not use backticks (`)?

I only want echo $(date) to return the date not the backticked version. echo $(date) # should return Wed Mar 6 09:50:41 EST 2019 echo `date` # should return `date`
1
vote
1answer
97 views

ZSH — Loop files, ignore certain patterns (no ls or find)

I just finished reading an article titled "Why you shouldn't parse the output of ls". I want to loop each file in a directory, and the article states that the following is one of the most basic and ...
2
votes
1answer
28 views

How to move to start of current command in zsh

I'm using vi mode with zsh, but I'm stuck in moving to start of current command when there are multiple lines in it. With 0, it just moves to the start of current line rather than current command. ...
2
votes
2answers
35 views

zsh: How to get value of variable based on a another variable?

I think a example would best explain what I need _v1="windows" _v2_windows="/mnt/d" _v2_osx="/Volumes/d" echo $_v2_`echo $_v1` I want to echo the value of _v2_windows but using _v1 to determine ...
0
votes
0answers
16 views

How do you escape “-” in a command in the Shell (Zsh)? [duplicate]

I am trying to rename a file named "-a" to "a" using the command line (zsh shell). I have tried the following mv \-a "a" mv '\-a' "a" mv "\-a" "a" but got mv: illegal option -- a usage: mv [-f | -...
0
votes
0answers
35 views

Open VIM with zle key binding

I would like to setup a bindkey to launch a fuzzy search across projects, home directories, files etc... and launch some command depending of the choosen file type. If the file is a regular file, I ...
45
votes
1answer
3k views

What is the difference between “…”, '…', $'…', and $“…” quotes?

Sometimes I see scripts use all of these different ways of quoting some text: "...", '...', $'...', and $"...". Why are there so many different kinds of quote being used? Do they behave differently ...
0
votes
0answers
47 views

Difference between zsh-history-substring-search and up-line-or-beginning-search

Is there a practical difference between history-substring-search-up and up-line-or-beginning-search? I've tried both out and they effectively seem to do the same thing (besides some highlighting that ...