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
The results are in! See what nearly 90,000 developers picked as their most loved, dreaded, and desired coding languages and more in the 2019 Developer Survey.

Questions tagged [zsh]

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

2
votes
2answers
2k views

Zsh icons broke in urxvt

so I am currently using manjaro linux and I am using urxvt as my terminal which I love so before all this starts switching the terminal is not an option, sorry if I am being rude. I installed zsh to ...
1
vote
1answer
25 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?
3
votes
2answers
2k views

Using zsh autocompletion for alias

I have created a few aliases for git in zsh, for example gch = git checkout, grb = git rebase --committer-date-is-author-date and some more complex useful zsh functions for git commands. But how can I ...
3
votes
3answers
3k views

zsh compinit: insecure directories, run compaudit for list

When I try to login as root, this warning comes up. luvpreet@DHARI-Inspiron-3542:/$ sudo su Password: zsh compinit: insecure directories, run compaudit for list. Ignore insecure directories and ...
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 ...
0
votes
0answers
43 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
37 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
39 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
13 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
73 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
509 views

Installed Anaconda -> strange behavior with DNF

I am using Fedora 26. Since I installed Anaconda, if I type in Terminal something like sudo dnf install gnome[TAB] I get Traceback (most recent call last): File "<string>", line 1, in <...
1
vote
3answers
60 views

How to add ~/.zshrc file into git?

I would like to create a backup of the .zshrc file in my ~/ directory and avoid versioning all other items. How to exclude all subdirectories and their content? For example: cd ~/subdirectory/ &&...
16
votes
1answer
860 views

Zsh tab completions not working as desired for partial paths

I want case-insensitive fuzzy completion for files and directories in zsh. After reading the manual for a few hours, this is what I came up with: zstyle ':completion:*:*:*:*:globbed-files' matcher 'r:...
20
votes
2answers
36k views

How to reset a shell environment?

This issue has been bugging me for a while, and although I've thought I've found my answer through EnvWatcher, unfortunately it only works on Bash. And I use zsh. I would like to replicate the things ...
1
vote
2answers
7k views

Do shells support recursion?

I'm trying to write recursive functions in my shell scripts. Consider the following code: function printA { if [[ "$1" = 0 ]]; then return else echo "a$(printA $(("$1" - 1)))" ...
16
votes
5answers
29k views

How to display the name of the current Virtualenv?

I'm using virtualenv, virtualenvwrapper, zsh, oh-my-zsh, terminator, on Crunchbang. I'm trying to display the name of the current virtualenv like so workon example (example)... I've tried many ...
6
votes
2answers
1k views

Renaming files in lexicographical order with a numerical pattern that increases sequentially with fixed padding

I have files such as a bb ccc abc emrls I would like to rename them so that, after sorting them (for example, lexicographically), each file gets the following name: 00001 00002 00003 etc where the ...
90
votes
8answers
146k views

Passing named arguments to shell scripts

Is there any easy way to pass (receive) named parameters to a shell script? For example, my_script -p_out '/some/path' -arg_1 '5' And inside my_script.sh receive them as: # I believe this ...
112
votes
2answers
18k views

Have backticks (i.e. `cmd`) in *sh shells been deprecated?

I've seen this comment many times on Unix & Linux as well as on other sites that use the phrasing "backticks have been deprecated", with respect to shells such as Bash & Zsh. Is this ...
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 ...
3
votes
0answers
59 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 ...
0
votes
1answer
26 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 ...
20
votes
6answers
10k 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 ...
2
votes
2answers
45 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 ...
18
votes
4answers
10k views

What does `zstyle` do?

zstyle seems like it's just a central place to store and retrieve data, like an alternative to export-ing shell parameters. Is that true, or is there more to it?
1
vote
1answer
15 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?
2
votes
3answers
266 views

Remove zsh autocomplete suggestion

When I type cd l and hit tab, zsh autocompletes to cd lightdm/ this is not a directory that is available to me (in fact I've uninstalled lightdm). How do I stop this from happening? I have ...
2
votes
2answers
269 views

Show a small key icon when the prompt asks for a password

How to configure bash/zsh to show a small key icon when the prompt asks for a password like Mac terminal? Is this even possible?
72
votes
4answers
20k views

How do you use the command coproc in various shells?

Can someone provide a couple of examples on how to use coproc?
2
votes
1answer
606 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?
2
votes
3answers
44 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
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
13 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
22 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 ...
20
votes
4answers
16k views

Is it possible to include file in config file of zsh? How?

I'd like to have a file eg. f with only zsh aliases (pureness reasons). Then I'd like to include f file in my .zshrc file, so that the aliases defined in f are visible in .zshrc. Is it possible? If ...
1
vote
2answers
133 views

What's the difference between ZSH themes, prompts, and terminal based themes?

I perhaps may have started overthinking this, but I also couldn't find a suitable explanation for it. I recently installed oh-my-zsh and it comes with several themes that change the way the "prompt" ...
8
votes
2answers
91 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 ...
8
votes
4answers
3k views

“command not found” when sudo'ing function from ~/.zshrc

I have a function in my ~/.zshrc: findPort() { lsof -t -i :$1 } The usual invocation is findPort 3306. I want to run it with elevated privileges. But I get "command not found". ➜ git 🍔 sudo ...
28
votes
4answers
19k views

What's the newline symbol in zsh's PS1?

I'm trying to setup a multiple line PS1, for zsh, but \n doesn't was parsed by zsh, PS1="%~\n %> " How should I set it up?
14
votes
5answers
33k views

How do you “disable” oh-my-zsh (and zsh) without uninstalling it?

I was trying new dev environments including zsh and oh-my-zsh. Now that I have installed oh-my-zsh, it starts by default on my terminals (iTerm2 and terminal) always start with zsh and with the ...
0
votes
1answer
974 views

zsh, oh-my-zsh, change current directory color

I've installed oh-my-zsh withe the "pure" theme (https://github.com/sindresorhus/pure) and the current directory is now being shown at the prompt. The problem is that it's shown in a dark blue color ...
1
vote
1answer
42 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 ...
50
votes
3answers
28k views

Switching to `zsh`: Are all bash scripts compatible with `zsh`?

I'm looking to switch from bash to zsh but concerned about compatibility of bash scripts. Are all bash scripts/functions compatible with zsh? Therefore, if that is true is zsh just an enhancement to ...
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
1answer
1k views

Why is my output not wrapping in tmux?

I am currently running tmux within Terminal.app on my Mac. When I execute a command that outputs a line longer than the available window, instead of wrapping onto the next line, it overwrites the ...
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 ...
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
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.