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
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
30 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
19 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
0answers
12 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 ...
7
votes
2answers
79 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
36 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
982 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
47 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
11 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
42 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
25 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
52 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
26 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
24 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
22 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 ...
43
votes
1answer
2k 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
18 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
41 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
26 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
34 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
104 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
39 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
11 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
5 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
45 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
45 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
32 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
127 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
61 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
95 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
30 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
51 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 ...
0
votes
0answers
81 views

Zsh Prompt Alignment Issues

Below is my zsh prompt configuration. Within Emacs (eterm) and Intellij terminals the display is compromised. Below is a representation of the display. % |...
2
votes
1answer
79 views

PS1 or PROMPT refusing to change in zsh

I enter in zsh: % PS1=">>> " But for some reason, the prompt is still the same: % echo $PS1 %B%F{red}%(?..%? )%f%b%B%F{blue}%n%f%b@%m %B%40<..<%~%<< %b%# Same thing with ...
1
vote
2answers
49 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/ &&...
0
votes
0answers
48 views

Is a .zshenv or .zprofile necessary for a proper/function zshell?

I have an issue where every terminal I open up has the first line: $home/.zshrc:1: command not found: followed by whatever I have as the first line in my .zshrc file. (See "What changes to a .zshrc ...
0
votes
1answer
58 views

What changes to a .zshrc file could cause every terminal one opens to output: '@home/.zshrc:1: command not found: xyz'?

('xyz' can be as far as I know, anything that is on my first line of .zshrc. Even an empty line as a first line of .zshrc returns the same output upon opening a terminal but ending with whitespace. I ...
0
votes
1answer
18 views

Zsh: lazy load bindkey to a function?

I have a zsh script that loads when start new shell with default is zsh. func1() { <..check if in a git repo, if not return..> <..code here..> } zle -N func1 bindkey '\eo' func1 The ...
4
votes
1answer
345 views

ZSH thinks unterminated quote if preceded by exclamation mark (!)

I have zsh 5.3 (through oh-my-zsh), if I run echo --message="foo!", I get unterminated quote prompt on the next line: $ echo --message="foo!" dquote> This doesn' happen in bash. When I drop the !...
1
vote
1answer
50 views

Ensure builtin command is run under pathological circumstances

Given a hostile environment such as: for word in builtin command type unfunction declare set unset alias; do eval "$word(){ echo $word function; }; alias $word='echo $word alias'" done Is it ...
1
vote
0answers
16 views

Is there any way to change $? from a zle widget?

I have a widget for mapping ^Z to fg: function ctrlz() { [[ $(jobs | wc -l) > 0 ]] && { zle -I fg } } However, since widgets can't change $?, the exit status of ...
1
vote
1answer
20 views

Understanding environment variable / shell syntax

I was just following the install instructions for zsh-autosuggestions and I don't understand what part of the following command is doing: git clone https://github.com/zsh-users/zsh-autosuggestions ${...
4
votes
0answers
40 views

Case insensitve tab completion zsh without increasing startup time significantly

So I wanted to get away from oh-my-zsh because it made my shell startup lag noticeably (>0.1s). Indeed, after removing oh-my-zsh the startup time went to 0.02s but now I started adding features ...
0
votes
1answer
39 views

Zsh: manually load completion functions

If I load completion functions at shell startup, but I spawn shell like a madman to work on the same folder. This is the case when I have multiple completion functions that target repository that ...
2
votes
2answers
49 views

Treat command like another for completion purposes

My zshrc includes the following function to create a directory and then enter it: function mcd () { mkdir -p "$*" && cd "$*" } The function itself works fine but I get odd behavior with ...
0
votes
2answers
53 views

Remove part of name after regex

I have a number of video files using a naming scheme like some-words-SxxExx.extension which is my preference. Unfortunately I have a lot of files in this format some-words-SxxExx-words-I-want-to-...
2
votes
1answer
42 views

how to pipe to a sourced function in bashrc file?

we all know how to pipe to shell scripts and installed programs like grep,awk ... but what about a sourced function in .bashrc or .zshrc ? this is a test function : function fff(){ echo "$@" } ...