Questions tagged [zsh]

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

Filter by
Sorted by
Tagged with
-1
votes
1answer
13 views

oh-my-zsh throws rrror when trying to access zsh profile in Mac OS Catalina

Trying to access either .zshrc or .zprofile doesn't work (it creates a new file). Trying to access the it with ~/.zshrc throws the same error. From my understanding I must have messed up one of my ...
4
votes
1answer
65 views

Does zsh use canonical-mode for the terminal?

I have been exploring terminfo and stty. If I run stty -a|grep icanon it appears that canonical mode is set, but if I try to turn it off with stty -icanon and check again, I see that it is still set. ...
0
votes
1answer
33 views

Global shell varible resets on shell startup

I've tried using fzf, and I've done export FZF_DEFAULT_COMMAND as per the instructions. I set it to ag -g "". For the rest of the session, echo $FZF_DEFAULT_COMMAND gives me ag -g "&...
2
votes
4answers
75 views

What shells support “value substitution” like MirBSD Korn Shell?

On Android (which uses mksh, MirBSD Korn Shell), there's a special syntax of string substitution (called "value substitution"): ${|commands} Instead of collecting output of the commands (as ...
2
votes
1answer
17 views

ZSH extends bash autocompletion

It's possible to make ZSH extends bash autocompletion? Bash can autocomplete almost every command in the system, and in ZSH i always need to enable a plugin for it. Here is an example (ignore the ...
1
vote
1answer
45 views

“which” command not work in shell script with #!/bin/bash but work with #!/bin/zsh [duplicate]

I have a sh file: #!/bin/bash echo $PATH date pwd which nano First three lines work with both #!/bin/bash and #!/bin/zsh but I got a ./script.sh: line 5: which: command not found with bash, but zsh ...
0
votes
1answer
19 views

Customizing hostname in zsh prompt

I am using zsh with oh my zsh and I wanted to get a thing like this: How can I do it? I want a setting to put somewhere, so that whenever I restart my terminal and my system, it always displays the ...
2
votes
1answer
52 views

emulate bash in zsh breaking dynamically assigned file descriptor

I am using a dynamically assigned file descriptor in a script as described in this post: zsh and POSIX equivalent of bash's `{var}>&1` The script itself is meant to be portable between bash ...
2
votes
1answer
30 views

Looping over files with specific column number 1 and number 2

I have a files test.txt which contains 1000 rows and 2 column: am-rls-dev am-nexus am-rls-dev cancel-ppd-nexus am-rls-dev h2h-autodebet-token-nexus am-rls-dev h2h-autodebet-transact-nexus am-rls-dev ...
1
vote
1answer
8 views

How can I run `gradlew clean build` in all subdirs starting with given prefix?

I have multiple project directories project-one, project-two, different-project. I want to run ./gradlew clean build within all these directories that begin with project-. Can I use xargs to do that? ...
0
votes
1answer
48 views

Configuration file for shell script?

Is it possible to define a configuration file for zsh scripts? I am running macOS 10.15 and the default shell is zsh. I have defined, i.e., alias abc="echo yes" in ~/.zshrc, ~/.zsh_profile, ~...
1
vote
2answers
55 views

zshrc export GPG_TTY=$(tty) says not a tty

I am trying to set up git commit signing using gpg. I have correctly set up everything. The only problem that I have is when I put export GPG_TTY=$(tty) in my .zshrc and restart a new Konsole window ...
9
votes
3answers
1k views

how to use 256 colors for background color in terminal

I know how to use 256 colors for text in terminal: printf "\033[38;5;196mhello\n" But for background color, I seem to be limited to the basic 8 colors only, ie: printf "\033[41mhello\n&...
2
votes
2answers
58 views

How can I override a multi word command with an alias in zsh?

I'm trying to override docker ps to be docker ps --format="table {{.ID}} {{.Image}} {{.Status}}" I've read this SO question and the referenced documentation, but I can't get it to work. I've ...
2
votes
2answers
46 views

Where should I install the zsh completion file as a package maintainer

I have a project that contains a completion script for zsh, where should I copy the completion file to when the user install (such as by running make install) the software ? I know there's some ...
-3
votes
0answers
36 views

Sudo returns an error on Kali Linux WSL2

I tried to install wine32. sudo apt install wine32 But sudo returns this error. sudo: error while loading shared libraries: libpcre2-8.so.0: cannot open shared object file: No such file or directory ...
0
votes
1answer
21 views

Scaping single quota in zsh alias

I like create any alias for docker commandas, and I need any alias use single quotes. I see post Escaping quotes in zsh alias but not work for me. Tried in .zshrc function dinfoip() { docker ...
1
vote
2answers
48 views

Difference between bash $HOSTNAME and tcsh/zsh $HOST

Is there any difference between bash's $HOSTNAME and zsh's $HOST? If no, is there a historical reason for bash to chose the $HOSTNAME variable when tcsh and zsh use $HOST?
0
votes
1answer
20 views

When I log in, on a tty instance it immediately asks for my sudo password

So I am attempting to log in on a tty, and it looks something like this : Arch Linux (tty1) hostname login: _ Password: _ Last Login at (Date) on (tty1) [sudo] password for user: _ And I think ...
2
votes
1answer
31 views

zsh: Read from stdin until a string delimiter

I want to read from stdin until a string delimiter MARKER=$'\0'"BRISH_MARKER" is encountered. I tried: ❯ unset br ; print -rn -- hi${MARKER}world | { IFS= read -d "$MARKER" -r ...
1
vote
1answer
33 views

zsh - change color for host and username

I just switched from bash to zsh and now I am trying to find out, how to colorize the Username and Host to have different color shemes. With bash my colorsheme looked like that: (orange)user (blue)@ (...
2
votes
1answer
141 views

zsh: check whether $PWD is on tmpfs mounted filesystem

I would like to change my zsh prompt color, if $PWD is currently on tmpfs mounted filesystem. Lets say for example, /dev/shm is a tmpfs filesystem. I can confirm that: $ grep /dev/shm /proc/mounts ...
1
vote
0answers
35 views

Why I can not get Terminator to use the default defined shell?

I am using ZSH as my default shell and OhMyZsh as well as the following command shows: ❯ echo $SHELL /bin/zsh I have been following what it is found at https://askubuntu.com/a/253819 but with no luck ...
1
vote
1answer
78 views

“Argument list too long” in ZSH with any command

I wish I could be more thorough in my explanation, but I have been using my same Artix setup for a while now, without any issues I couldn't fix myself. However, after installing VirtualBox (Which I ...
0
votes
1answer
30 views

Overwrite bg color of zsh prompt

I'm using zsh with prompt fade, I do not have oh-my-zsh installed. My terminal background is dark blue, not black, but the prompt is being printed on a black background. How can I overwrite this so ...
3
votes
1answer
29 views

Edit a Zsh command with external editor and replace the original command

I'm using Zsh with Zim. I've set up a key binding for editing the current command in Neovim by placing the following into .zshrc: bindkey -v export VISUAL=nvim autoload edit-command-line; zle -N edit-...
1
vote
1answer
50 views

Queue multiple jobs after current one in shell

On previous questions similar to mine, the proposed solutions are all involved suspending the current foreground task with Ctrl+Z and then running fg && ... or fg ; ... (and maybe sending the ...
1
vote
1answer
15 views

How can I add a hot-key to readline for zsh or bash that takes fills in the 2nd parameter to copy but with .bak?

I'd like to make a hot-key for this task I sometimes need to perform: %> cp file.txt.1 file.txt.1.bak Where I've repeated the file name but with a .bak on the end. I'd like to instead just type: %...
3
votes
1answer
113 views

What does the '.' dot mean as a working directory?

I'm not referring to the . you see in shell commands or in the output of ls -a. I just ran an install script for a vpn application, and after the command exited, my terminal prompt was in the . ...
3
votes
1answer
25 views

How to execute ctrl+r query as-is instead of a match?

Sometimes when I reverse-search cmd in a shell I don't find a correct match and just want to execute search query as it is. Is there a way in bash/zsh and friends to execute it without discarding ...
0
votes
1answer
28 views

completely disable zsh completion system

I am trying out fzf completion and want zsh completion / suggestions to be completely disabled. I have not used the following in my .zshrc: autoload -Uz compinit compinit Still it is giving some ...
1
vote
1answer
41 views

debugging zsh completion method

I am trying to debug a completion method. This method is supposed to present with all the directories within these three folders. I verified that compinit is loading it correctly. tried tracing and i ...
0
votes
1answer
30 views

tab completion of /proc/self/fd/ shows different completions compared with listed contents

Using zsh, if I try tab completion of the following command ls /proc/self/fd/ then I see the following: files 0@ 1@ 10@ 11@ 12@ 13 2@ 3 However, when I press enter (without completing) I ...
1
vote
1answer
28 views

zsh slow doing eval with path

I have had a performance issue for quite some time when doing autocompletion in a folder using zsh. Finally, I dedicated some time, to try to understand WHAT caused the problem, and HOW to solve it. ...
1
vote
1answer
20 views

How to define arrays in zsh with user supplied key names

I just started using zsh and I can't figure out how to define arrays with user defined keys. (I'm following the documentations on arrays: http://zsh.sourceforge.net/Doc/Release/Parameters.html#Array-...
5
votes
2answers
182 views

How to iterate over array indices in zsh?

In bash we can iterate over index of an array like this ~$ for i in "${!test[@]}"; do echo $i; done where test is an array, say, ~$ test=(a "b c d" e f) so that the output looks ...
0
votes
1answer
36 views

Running a single command in a shell other than the default shell

I'm switching over to zsh from bash, but as I'm getting used to everything, is there a way to run a single command with a shell other than my default shell, so I can maintain my normal workflow? ...
1
vote
2answers
97 views

How can I use sed to display the lines between the first blank line and the last line?

I'm trying to parse the response from my web server in a shell script. This is the response: HTTP/1.0 404 NOT FOUND Content-Length: 223 Content-Type: application/json Last-Modified: Fri, 21 Aug 2020 ...
0
votes
1answer
27 views

Zsh Hook Function Definitions as arguments

I would like to know if it's possible to define hook functions as arguments or env var when launching zsh instead of defining it in .zshrc or prompt. For example ; zsh -F preexec() { date } -F chpwd() ...
2
votes
1answer
55 views

Is it possible for a subshell to execute something in the parent shell?

I have a shell script which must be sourced, because its purpose is to set a bunch of environment variables in the current environment. In case future me forgets, the script begins with: #!/usr/bin/...
1
vote
0answers
24 views

Funtoo Keychain keeps asking for password when logging in using SSH

I have followed the instructions here https://www.funtoo.org/Keychain and added eval `keychain --eval --agents ssh --inherit any id_rsa` to - I have tried both but the result was the same - .zshrc ...
0
votes
1answer
26 views

How can I make vim only write to file after buffer has been modified?

I have this function which sources my .zshrc only if it has been modified in vim but I recently reinstalled Windows and WSL and then used my old .zshrc and .vimrc to get my setup back but this ...
1
vote
1answer
34 views

Lost my Aliases after installing Oh my Zsh

I had several Aliases defined on my terminal Zsh (Mac OSx), after installing Oh My Zsh I cannot execute my old aliases, and by running the alias I see a list of many new aliases added by Oh My Zsh. ...
0
votes
1answer
42 views

zsh - optimize copy, cut, paste using ctrl+c, ctrl+x, ctrl+v

I am using the following config in my .zshrc. if [[ -t 0 && $- = *i* ]] then # change Ctrl+C to Ctrl+I stty start '' stty stop '' stty quit '' stty erase '' stty kill '' stty eof '' # Ctrl + D ...
3
votes
4answers
129 views

Source a file after ssh login drops to prompt

One-liner question: How do I automatically source a remote file on remote host after logging in via SSH via a bastion host? I need to source a file containing a list of aliases + shell user defined ...
0
votes
0answers
13 views

Local variables in zsh functions and their return code [duplicate]

Consider the following zsh function function foobar() { local foo=$(fzf) && echo "$foo-bar" } if instead of selecting one of the results of the fzf command I exit fzf without ...
0
votes
1answer
11 views

How multi-select work in rofi dmenu

I am using rofi 1.5.4 Suppose I run the command echo -e "Option #1\nOption #2\nOption #3" | rofi -dmenu -multi-select | xargs -I{} echo {} What keys shall I use to select multiple menu item?...
0
votes
0answers
33 views

Backspace deletes a whole word zsh

I'm currently having a minor issue with zsh, as since the last update, pressing backspace deletes a whole word, which is quite inconvenient. I looked for a solution, thought it may come from a sneaky ...
1
vote
1answer
32 views

List all parent directoriy hierarchy

How to get the list of all parent directories. Suppose I am currently in % pwd /media/blueray/WDPurple/_DataBackup/_Work/_NotesFilteredADOC/linux/shell-command-language/zsh-scripting I want 0 /media/...
1
vote
2answers
39 views

pad the prompt with dots if the length of the prompt is less than n

Thanks to Klas Mellbourn my current prompt looks like # this variable can be changed later to change the fraction of the line export PROMPT_PERCENT_OF_LINE=40 # make a function, so that it can be ...

1
2 3 4 5
42