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.

1
vote
1answer
38 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 ...
2
votes
2answers
32 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
21 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
26 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
52 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
38 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
42 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
14 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
78 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
34 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
46 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
35 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
62 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
19 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
36 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
14 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
23 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
31 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
92 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
45 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
50 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
46 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
27 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
74 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
27 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
31 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
29 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 ...
44
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
34 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 ...
1
vote
3answers
58 views

“==” logical operator and zsh version 5.7.x (installed using Homebrew)

Been getting errors on my scripts when using this operator. I've some online documentation and double equals should supposedly work. Any ideas? Zsh reference guide: http://zsh.sourceforge.net/Doc/...
1
vote
2answers
45 views

Show possible completions in zsh (possible-completions in bash)

I have recently switched to zsh from bash. Deep in my inputrc, I had "\e[/": possible-completions set. This allowed me to see all completions at a given point, without applying them. This was really ...
0
votes
2answers
36 views

Batch renaming when the destination file need spaces

I need to rename a batch of markdown files with random names based on the title name, and the destination name need to be with spaces (this is a spec). I'm trying this one-liner for i in *; do mv $i $...
36
votes
3answers
4k views

Why is opening a file faster than reading variable content?

In a bash script I need various values from /proc/ files. Until now I have dozens of lines grepping the files directly like that: grep -oP '^MemFree: *\K[0-9]+' /proc/meminfo In an effort to make ...
2
votes
2answers
110 views

Prompt to reflect sshfs mountpoint?

I use sshfs to remotely mount a remote folder to my local machine, the problem is that I need a way to know that I'm working under remote folder on local machine OR local folder to avoid accidentally ...
0
votes
0answers
98 views

How to use chsh with ldap authentication

How to use zsh as default when starting an ssh session to a remote chef server using LDAP for authentication? tom@chef:~$ chsh -s /usr/bin/zsh Password: chsh: user 'tom' does not exist in /etc/passwd ...
1
vote
0answers
15 views

How to setup a git contrib script with zplug?

I want to add auto-installation of diff-highlight thanks to zsh zplug: zplug "git/git", as:command, use:"contrib/diff-highlight/diff-highlight" \ hook-build:"cd contrib/diff-highlight && ...
0
votes
0answers
7 views

Deactivate case sensivity on oh-my-zsh history fzf

How to disable case sensitivity on fzf for history search? I try export FZF_COMPLETION_OPTS='-i' on my config file without success.
0
votes
2answers
58 views

How to get file path which was selected and make copy in dolphin KDE and paste on zsh?

➜ ~ cat .zshrc | grep xclip alias c="xclip -selection c" alias -g v='"$(xclip -selection c -o)"' ➜ ~ v zsh: 没有那个文件或目录: file:///home/roach/Downloads/pure.png ➜ ~ The Chinese words "没有那个文件或目录" ...
1
vote
1answer
112 views

Personalize colored-man-pages zsh plugin colors

I just installed the colored-man-pages zsh plugin. It works well, but I have an ugly color output on the bottom message: What is the proper way to personalize the color of the plugins without ...
1
vote
1answer
33 views

How to get variables expanded in output of jobs command

As you can see in the following output the variable $i in the output of ps aux is expanded to sleep 1, sleep 2, etc. Is there a way to make zsh do the same? In the jobs output all the commands get the ...
1
vote
1answer
305 views

Split string by space in ZSH

Give this file.txt: first line second line third line This works in bash: while IFS=' ' read -a args; do echo "${args[0]}" done < file.txt To produce first second third That is to say, we ...
0
votes
3answers
64 views

Shortcut to `cd` into the 2nd folder in a directory

CONTEXT I am in a directory with 3 folders. After executing ls -1 they are ordered like so: folder1 folder2 folder3 I want to quickly cd into folder2. I was able to write a function to quickly cd ...
2
votes
2answers
137 views

Find array length in zsh script

Is there a way to find the length of the array *(files names) in zsh without using a for loop to increment some variable? I naively tried echo ${#*[@]} but it didn't work. (bash syntax are welcome ...
0
votes
0answers
59 views

Ruby, Rbenv not working because zsh is not sourcing etc profile.d

I switched my shell bash and noticed that zsh shell does not source /etc/profile.d. As Zsh is at times positioned as a more advanced alternative to bash, should it not by sourcing etc profile? Now ...
3
votes
1answer
66 views

Prevent completion of files for 'make' command in zsh shell

Context zsh shell, oh-my-zsh framework, no special zsh's configuration (same problem with or without zsh-completions): see .zshrc at the end. Trouble If a directory contains: a makefile with ...