Questions tagged [zsh]
Zsh is a shell with many advanced command-line and scripting features.
2,257
questions
0
votes
0answers
12 views
Zsh: Is it possible to disable history expansion inside double quotes?
Is it possible to disable history expansion inside double quotes?
I do not want history expansion to be completely disabled, as I still use it, but I see no reason to expand the history inside a ...
0
votes
1answer
15 views
zsh function to export multiple variables from clipboard clipboard
I want to be able to take the contents of the clipbard and evaluate it in zsh without showing the contents of the clipboard
export FOO=BAR
export BAR=BIZ
export BAZ=FOO
I've tried
function aws-eval-...
-2
votes
1answer
75 views
Difference between the shells [closed]
I've been using Linux Mint since March 2020, and I haven't used any shells other than the Bash shell.
So what exactly is the difference between the Bash shell and the other shells (Fish, Zsh, Ksh, ...
0
votes
0answers
21 views
What is the the purpose of having both $PATH and $path? [duplicate]
I'm using Mint 20.1 (update: I also use zsh as my shell) , and I notice that there are two very similar environment variables dealing with path:
$PATH, which lists every path directory, using colons ...
1
vote
2answers
53 views
Program launches before piped into
man -k . | fzf -e --tiebreak=begin | awk '{print $1}' | xargs man -Tpdf | zathura -
# searches for a man page and then outputs it as pdf to zathura
This is the command , it works great , other than ...
0
votes
0answers
18 views
“zsh compinit: insecure directories and files” but paths are not group writable
I am seeing zsh compinit: insecure directories and files when I run compinit. Yes, I have seen this SO post and this U&L post, as well as all sorts of related posts. For all of those examples, the ...
1
vote
1answer
26 views
How do I duplicate file n times and then create a function in .zshrc?
This may be a duplicate of Duplicate file x times in command shell and is definitely a duplicate of How to duplicate a file a number of times while embedding an index in each file but the person who ...
1
vote
1answer
24 views
Is it possible to change the terminal colour based on Nightshift (sunset/-rise)
I want to have a conditional terminal color based on the Nightshift (sunrise/-set).
I am using macOS BigSur 11.2.3 and the default terminal with zsh.
1
vote
2answers
51 views
bash function command not found in cronjob
In my crontab , I set following bash function and applied it for my job. it is indicated to add timestamp to the log.
adddate() {
while IFS= read -r line; do
printf '%s %s\n' "$(date)&...
0
votes
1answer
24 views
How can I disable kitty's paste from escaping?
If I have the string and copy that with CTRL+SHIFT+C
https://test.invalid/?foo=bar()&baz=$quz{}
And I paste that into the terminal I see the following,
https://test.invalid/\?foo\=bar\(\)\&...
1
vote
1answer
19 views
Rename TMUX window based on custom function in ZSH
I have a custom function in my ~/.zshrc file:
function getCustomWindowName {
# runs 'sed' on 'pwd' to get special dir name
# and set it to $workspace
if $workspace is valid; then
echo $...
0
votes
1answer
28 views
How do I NOT display pair of duplicates in (zsh) history?
My default shell is zsh and let's say my history looks like this:
command a
command b
command a
command b
command c
command b
command a
command b
command a
command b
Now what I would like to have is ...
0
votes
2answers
51 views
Sharing environment variables between zsh and bourne shell (for crontab)
I set JAVA_HOME in .zshrc:
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre/
which is fine for interactive programs. But I have JVM programs running via cron, which uses Bourne shell. The ...
0
votes
0answers
32 views
What is' [quote>'? [duplicate]
I'm a newbie when it comes to using terminal. I accidentally misspelled clear as c'ear in the terminal and the command line began with [quote> from there on instead of the current directory. Can ...
27
votes
3answers
2k views
How can I prevent the second command in a chain while keeping the first one running?
Yesterday before going to sleep I started a long process of which I thought it would be finished before I stand up, therefore I used
./command && sudo poweroff
my system is configured to not ...
0
votes
1answer
12 views
How to put a linux command output into this json string in aws cli?
I want to be able to use aws cli to update a row in dynamodb and change value of some of its fields.
One of them is a boolean. The other is a number field which contains the unix timestamp.
aws --...
0
votes
1answer
47 views
How to keep hostname on title when I run commands
I'm trying zsh on Ubuntu 20.04 from Putty. One good feature I like is that zsh automatically show the running command on window title, which is good for forgetful me who forget what is running.
...
0
votes
1answer
83 views
Bash coming on zsh, why?
I currently switched to zsh from bash but, when I type wrong command, instead of zsh:<wrong-command>: command not found, comes bash: <wrong-command>: command not found it is something ...
1
vote
1answer
18 views
How to change the prezto and zsh theme prompt?
I installed yadr and prezto to style the zsh prompt.
I'm using the steeef theme:
https://github.com/sorin-ionescu/prezto/blob/master/modules/prompt/functions/prompt_steeef_setup
How do I change the ...
1
vote
1answer
18 views
disable cd tab completion for __pycache__ in zsh
when I type
cd path/to/python_package/
and press tab to try to fill path/to/python_package/only_module for example, I am stopped dead in my tracks! By
$ cd path/to/python_package/
__pycache__/ ...
0
votes
0answers
107 views
Output of “ls > a.txt | wc” and “ls | wc” in the zsh shell [duplicate]
Using the zsh shell, I observe the same output when I execute ls > a.txt | wc and ls | wc. Could someone confirm my understanding regarding the same.
In the first command the STDOUT is redirected ...
0
votes
1answer
22 views
ZSH prompt disappears after typing too much
When I type for too long with zsh, the prompt disappears and it leaves a single character on the same line as the rest of what I was typing, the rest goes to a new line below it. Not sure how to tell ...
1
vote
1answer
35 views
Zsh: How to make `${x:?}` return non-zero in case of empty `$x`?
How to make ${x:?} return non-zero in case of empty $x? By default, it exits the shell (subshell in this example) with 0.
function sth() {
local url="${1:?}"
...
}
(sth) ; echo $? # ...
0
votes
0answers
24 views
Ubuntu Login Loop with Ctrl+Alt+F3 Terminal unable to execute commands
Like the question says, I'm caught in a standard Ubuntu Login Loop. However I have been unable to resolve this with the information from pre-existing posts.
(Fyi I'm using zsh and am unable to change ...
1
vote
0answers
26 views
Change zsh tab size
I wanted to change the tab size (the amount of spaces a tab uses) used in my terminal, but it didn't work.
I then found out, that my shell (zsh) inserts a fixed amount of 8 spaces instead of a tab.
I ...
0
votes
0answers
18 views
Switchign from bash to zsh breaks compose (AltGr) key
I came across this post and tried the suggestions to no avail: zsh broke compose key and special chars
Summary:
After installing zsh none of the special characters usually available by pressing the ...
2
votes
2answers
42 views
zsh syntax to expand variables' names matching a prefix
TL; DR: is there a zsh equivalent of Ksh/Bash's "${!varnamepfx@}" expansion?
So that, for example, if I have the following variables set:
[...]
foo='random value'
bar=$'amazing\n value'
baz='...
5
votes
2answers
171 views
coproc and named pipe behaviour under command substitution
I have a requirement to make a function in a zsh shell script, that is called by command substitution, communicate state with subsequent calls to the same command substitution.
Something like C's ...
0
votes
0answers
18 views
how to set tmux window title and see this in choose-tree
I have two MacOS machines both running zsh and tmux for a local developer environment. The machine I'm stumped on (referred to as machine 2) is reflected in the screen shot. What is not happening is ...
2
votes
2answers
28 views
Can zsh kill-word ignore escaped spaces?
I want kill-word to turn ls Dir\ A/Long\ File\ Name into ls Dir\ A/ if I call it at the end of the line. I know I can delete to / by modifying $WORDCHARS, but I found no way to ignore escaped spaces.
0
votes
1answer
27 views
Defining zsh aliases and functions systemwide
What's the most efficient way to export the functions/aliases defined in my .zshrc to be used anywhere. For example in my .zshrc
_foo() {
echo "bar"
}
And then invoke _foo in any script.
0
votes
0answers
33 views
zsh problem counting the number of lines at the end of a pipe in a variable
I've recently switched from bash to zsh, and now it seems I'm experiencing my first compatibility issue.
I'm trying to write a shell script that checks exif date and time info in image and video files,...
0
votes
1answer
43 views
Why does my MacOS terminal ask for my password every time I start it?
I am new to MacOS (and the world of shell), and this started happening after I tinkered with some settings while installing Homebrew. I can get out of this mode and back to the normal zsh shell using &...
1
vote
1answer
47 views
Finding indices and substrings of strings in Zsh?
I'm making functions in my zshrc file to help me navigate to certain frequently visited webpages. For instance, calling 61b would open https://sp21.datastructur.es/, 61b lab6 would open https://sp21....
1
vote
1answer
28 views
Displaying only final branch of current working directory on command prompt?
My current command prompt displays the entire path from my home directory to my cwd. For instance a possible command prompt would be ~/Desktop/images/japan λ. How do I make it such that it always ...
1
vote
1answer
67 views
Why does “cat >> file” not work in zsh with pasted text?
I had never heard of zsh before, but when I updated to Catalina, MacOS pushed me to drop bash in favor of zsh. But I recently have observed some annoying incompatibilities when trying to append to the ...
0
votes
1answer
40 views
How to fix powerline fonts and symbols error in shell?
I've installed Arch about a week ago, and since then I been struggling with the powerline fonts. But after installing the pkg powerline-fonts, I configured the .zshrc file by adding these lines:
...
0
votes
2answers
38 views
How do I use multiple .zshrcs?
I want to use different zshrcs and choose one using a single file tat holds variables and loads them up. I've tried looking it up, but there are only for iTerm2. I would appreciate any support. Thank ...
0
votes
1answer
24 views
Long lines wrap problem with zsh terminal
I have a long wrap problem with my terminal. Can anyone help me modify my prompt environment variable to overcome this issue? Here is my prompt env variable:
function parse_git_branch() {
git ...
0
votes
0answers
21 views
Conditional Git alias within zsh: “parse error: condition expected: cd” [duplicate]
I'm trying to implement a simple stack of git-related aliases for my personal dotfiles.
alias gs="[[ $(git rev-parse --is-inside-work-tree &> /dev/null) ]] || cd $D && git status -...
1
vote
1answer
42 views
Copying text with Ctrl + C when the Zsh line editor is active
I've added some keyboard shortcuts in my Zsh to enable selecting words.
In order for the selection to do something, I would like to use Ctrl + C to copy it. However I would also like to use Ctrl + C ...
0
votes
0answers
5 views
Fail to update oh-my-zsh: nvim --interactive unkown argument
when i try to update my oh-my-zsh installation with
ozm update
i get
nvim: Unknown option argument: "--interactive"
Obviously it has something to do with nvim, but what am I doing wrong?
0
votes
3answers
84 views
How to grep special characters, “^A”, ^[, ^[[
I know how to output bindkeys using bindkey.
I can grep a word.
$ bindkey | grep line
"^A" beginning-of-line
"^E" end-of-line
"^J" accept-line
"^K" kill-line
......
0
votes
0answers
105 views
zsh: command not found: module - module load not working on my Mac
If I try to module load any module, I get zsh: command not found: module.
I have Modules installed in /usr/local and I have added source /usr/local/Modules/init/bash to ~/.bashrc as suggested in ...
5
votes
2answers
100 views
Set a key with spaces in an associative array in Zsh
In Bash (4 or above), if I have an associative array dict, I can set its value like dict[apple count]=1 and I would be able to access it with ${dict[apple count]}. Does Zsh allow space in key names? ...
2
votes
1answer
18 views
zsh completion in the form --host=hostname
I have a custom script that requires one argument in the form of --host=hostname, and allows one optional argument -n, --dry-run.
I have created zsh completion, where the optional argument is being ...
2
votes
1answer
39 views
How to pass condition statement as argument to functions in zsh?
I have defined a function similar to the following (as an alias),
testif() {
([ $1 ]) && echo "true" || echo "false"
}
..and then was able to call testit "1 == 2&...
2
votes
1answer
27 views
“Inlining” a zsh function
In my .zshrc, I have this function definition, it prints out vim history and opens chosen file in vim:
vim_hist() {
n=$(sed -n "s|~|$HOME|;s|^> \(.*\)|\1|p" ~/.vim/viminfo | fzf)
[...
1
vote
1answer
76 views
zsh-cursor displacement over ssh
I am running Arch Linux locally. When I connect to my remote Debian 10 server via ssh, the cursor behaves in an awkward way:
As long as every command returns statuscode 0, everything is fine. When ...
0
votes
1answer
30 views
I used to use a tool for zsh but I forgot what it was
I use ctrl-r frequently on zsh to iterate over previous commands. I used to have this 'modification' where ctrl-r actually displayed matches for me as I was typing the search string.
Does anyone know ...