Questions tagged [zsh]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
34 views

About Precommand Modifiers in zsh

Background While the zsh documentation (ch 6.2) provides a description for what precommand modifiers can do, it fails to provide examples for each type: -, builtin, command, exec, nocorrect, and ...
2
votes
2answers
29 views

What is the zsh equivalent of "pushd -n" in bash?

I want to push a directory onto the directory stack in order to refer to it using "tilde shorthand" (eg. ~1 refers to the second entry in the directory list), but I don't want to actually ...
0
votes
0answers
20 views

Dynamically change number of columns in ZSH

I like using W3M to read articles online, and I want to create reader-mode functionality whereby I make the terminal full-screen and restrict the output of W3M to the center of the screen. I run W3M ...
0
votes
0answers
33 views

Zsh cursor is on the dollar sign after changing directory

Why when I do cd to a directory, the cursor is placed on the dollar sign. I'm using urxvt, however it also happens in another terminal. The primary prompt string is defined as: PS1='[%{$fg[$NCOLOR]%}%...
2
votes
1answer
99 views

Why does echo "$ZDOTDIR" return nothing?

Background In Chapter 5 of the ZSH manual it states: Commands are first read from /etc/zshenv; this cannot be overridden...Commands are then read from $ZDOTDIR/.zshenv. Issue I wanted to view what ...
0
votes
0answers
22 views

Shift + arrow keys adding characters to terminal instead of selecting text

I am running macos monterey (Version 12.0.1 (21A559)). I am using zsh, on iterm 2. With omz installed, and powerlevel10k theme installed. Recently I noticed that I cannot select text in terminal using ...
3
votes
3answers
354 views

how to recursively remove embedded carriage return in filenames

Is there a way to recursively remove a carriage return \r character that has been appended to thousands file names across a hierarchy of dozens of folders? Also, not all files were affected. For ...
0
votes
0answers
15 views

How to solve spawn bin/zsh ENOENT?

I am installing dependencies for a project using NodeJS, Angular and Node-Sass, all goes ok when installing both Node and Angular, but when installing Node-saas i got an error: npm ERR! code ...
1
vote
1answer
44 views

zsh case-insensitive globbing

Context: macOS Catalina (zsh) This script is to process all JPEG files. This script does not process .JPG files, however it does process .jpg files. top=/Users/user/Desktop/ for file in $top/**/*.jp*...
0
votes
1answer
17 views

Set custom shell history file [duplicate]

How to set an alternative path for the zsh history file instead of the default ~/.zsh_history?
1
vote
2answers
225 views

Please explain the behavior of these parameter expansions using IFS?

I'm trying to figure out how to use the ${parameter%word} expansion with $@ and $*. It started by trying to make a script to combine pdfs using ghostscript, but I ran into some weird behavior with ...
0
votes
1answer
56 views

What does $^@ (dollar caret at) mean in a shell script?

I found references for parameter expansion, but none of them explain what $^@ does. From context, I think it's used to expand e.g. ~/$^@ into ~/$1 ~/$2 ..., but I'm not sure, and I can't find any ...
3
votes
1answer
382 views

what is this zsh syntax? name()true

I am assuming the following block represents a function, but it may not: mounted()true if ... fi ... && mounted I want to understand what that construct is. I did not find similar syntax ...
1
vote
1answer
34 views

Zsh can't find terminal definitions on Mac

Perhaps it's from updating Brew (I use Homebrew Bash and Zsh on Mac), but Zsh can no longer find xterm definitions. For instance, in my .zshrc file I have the following: export TERM=xterm-256color ...
0
votes
0answers
27 views

Equivalent of PSReadLine for bash

For my Windows Terminal using Powershell I have the plugin PSReadline which gives me some pretty handy features. For instance a navigatable list view of my history when I start typing. So if I type cd ...
0
votes
0answers
19 views

Getting zsh to display possibilities rather than autocompleting

I just made a new manjaro KDE install and have been working a bit in the konsole, which looks and mostly works amazingly. The default shell seems to be zsh. I only have one issue however, I prefer ...
0
votes
0answers
55 views

`trap` shell command: Is there a way to STOP trapping once an event is complete?

I'm working on a BASH script (see below), that will vomit out the keycodes on keypress for my own use in a different, unrelated script. Contained therein is a trap command for SIGINT which, amongst ...
1
vote
1answer
18 views

Disable zsh "smart" autocompletion for gem command, but keep ordinary path completion

I'm on a Mac running macOS 12.0.1 and trying to switch over from bash to zsh. When I'm trying to issue something like the following command: gem install pg -v 1.2.3 -- --with-pg_config=/opt/homebrew/...
1
vote
2answers
48 views

create an alias on ZSH but need to type it twice

I'm trying to create an alias on ZSH. The aim of the alias is to activate a python virtualenv. I've put a line in my .zshrc alias SOU="source /home/andykw/.zshrc && source $(setopt ...
0
votes
1answer
35 views

Would including a line like "source ~/rc/.zshrc" in my ~/.zshrc be equivelent to including all the text from ~/rc/.zshrc in my ~/.zshrc?

I want to keep my ~/.zshrc in a github repo, and since I don't want to make my ~ folder a git repository, I plan to move my ~/.zshrc to a folder called rc and then include source ./rc/.zshrc in my ~/....
3
votes
1answer
61 views

Permission denied on trying to "rm -rf" my own directory on macOS command line

I have noticed rm -rf has a strange behavior in my macOS BigSur. I created a directory for a font installation: ~/code ❯ ls -la 10:06:54 total ...
0
votes
0answers
19 views

Autostart Fbterm then Tmux in Arch Linux

i have installed Arch Linux and i want to use the OS without GUI. so i installed FBTERM and TMUX to assists my life in GUI-less OS. both programs running perfectly, so i want to make FBTERM and TMUX ...
1
vote
1answer
38 views

How to prevent zsh from storing "up" commands to history?

For example, say I do a command like appbuild by hitting up arrow ten times in a row. Now, if I want to go back to the last unique command before that, I have to hit up ten times in a row. Any way to ...
1
vote
1answer
60 views

Exiting zsh on the Terminal in mac doesn't quit the window

As I exit out of zsh on the terminal on MacOs, it gives me a message: logout Saving session... ...copying shared history... ...saving history...truncating history files... ...completed. [Process ...
1
vote
1answer
22 views

How can I make an autocomplete function for zsh that can allow for a random number?

I have a small script for managing tickets in gitlab repos. When I type ticket and press tab, I'd like to see: % ticket new -- create a new ticket # -- Number of ticket -v -- increase verbosity ...
1
vote
2answers
36 views

zsh: rename file if file in subfolder has same name

There is the following file structure: charlie ├──this-file.foo.1 ├──this-file.foo.2 └──this-file.foo.3 foxtrot ├──another-file.foo.1 ├──another-file.foo.2 ├──another-file.foo.3.bar ├──another-file....
4
votes
2answers
107 views

Repeat char n times in zsh prompt

I'm working on a custom ZSH prompt and I want to repeat a char n times in a string (such as spaces for padding). This string is printed with print -rP (the -r flag ignores echo escape conventions and ...
3
votes
2answers
112 views

Rename file sets with multiple (incl. compounded) extensions in shell

I have a list of file sets with a lot of extensions, but unique names. filename-1.foo.001 ... filename-1.foo.020 filename-1.foo.baz filename-1.foo.bar1-2.baz ... filename-1.foo.bar7-8.baz ...
0
votes
1answer
46 views

Converting a bash script to use in zsh

The following bash script was posted in this thread as a means of setting an ST (terminal window's) title in DWM (X window manager). While adding this segment to by .bashrc has the desired result, I ...
0
votes
5answers
86 views

How to move every file in a folder to a subdirectory of the same name?

Say I have a bunch of files in a directory filename-1.ext1 filename-1.ext2 filename-1.ext3 filename-2.ext1 filename-2.ext2 filename-2.ext3 filename-3.ext1 filename-3.ext2 filename-3.ext3 I then want ...
0
votes
1answer
25 views

What is the best way to auto-remove .zsh_history after a certain time?

I feel like there is no ZSH setup option to auto-remove .zsh_history after a certain time (e.g. older than one month from now). What would be the simplest hack to achieve it?
1
vote
2answers
296 views

loop through one file extension or the other in bash or zsh

This is syntactically correct: for f in *bw;do echo $f;done But How would I add an extension to loop through one or the other? The following doesn't work: for f in *bw|*txt;do echo $f;done And this ...
0
votes
2answers
65 views

Installing zsh from source file without root user access

I clone the source of zsh source file from github, after that I ran the command bash install-sh and ./install It prompt to me that No input file specified . Then follow the instructions I tried ...
1
vote
0answers
44 views

!!: command not found

Recently, I was getting a bit frustrated about not running commands as admin, and started using sudo !! a lot. I decided that, for ease of use, I'd create an alias ffs for that exact line. I added the ...
2
votes
1answer
30 views

zsh pipestatus disappears in the following prompt

I am on zsh 5.8 (arm-apple-darwin20.2.0). Unlike the way PIPESTATUS in bash is available to read during the next shell prompt, pipestatus of pipe in zsh seems to disappear in the following prompt. ❯ ...
1
vote
1answer
40 views

zsh script to rsync multiple files from same remote directory

I'm running Debian Bullseye (if that matters), and I'm writing a zsh script to use rsync to copy multiple files/directories (passed as arguments to the script) from a given remote directory. They're ...
1
vote
1answer
59 views

zsh: understanding sequence of redirections and pipe with pointers

In zsh, echo "hello" 1>&1 1>&1 1>&1 | cat prints hello 8 times, while echo "hello" 1>&1 1>&1 1>&1 1>&1 | cat prints hello 16 ...
0
votes
0answers
40 views

Ctrl-D doesn't close the terminal inside VIM after piping the output of cat to clipboard (needs :q)

It's a very specific problem, so I'll try to provide everything that I think might be relevant. I have these two aliases in my ~/.zshrc for copying and pasting the output of commands: $ grep xclip ~/....
0
votes
1answer
74 views

Closing stdout fd gives error, while closing stderr fd does not

The following test code gives error "bad file descriptor". Why is that so? This is just a test code to understand file descriptors and their interaction with pipes. Example 1) ❯ echo "...
1
vote
1answer
92 views

Redirection to stderr works in bash, not in zsh

In bash, ❯ echo "hello" 1>&2 | echo "world" hello world In zsh, ❯ echo "hello" 1>&2 | echo "world" world More than a way around this, I am ...
0
votes
1answer
33 views

zftp connection refused, sftp works

When I try to sftp into a virtual machine's IP address it works well (I am able to do all the sftp provided operations). But when I try to use zsh's zftp for the same IP address, the connection is ...
0
votes
2answers
38 views

I cannot set env variable on zsh

I am using Kali linux: lsb_release -a " Distributor ID: Kali Description: Kali GNU/Linux Rolling Release: 2021.2 Codename: kali-rolling " i set env variable export DB_USER=...
1
vote
2answers
99 views

How can I change the location of .xinitrc and .zsh* files

I want to change the location of .xinitrc, .zshrc and .zshenv to ~/.config/x/xinitrc, ~/.config/zsh/zshrc and ~/.config/zsh/zshenv, but without simlinking them. How can I achieve this? Do I have to ...
0
votes
0answers
32 views

Prevent zsh's time command from giving output of program

With zsh on my Terminal, time hello.out gives Hello World user 0.002 system 0.003 total 0.006 I have configured my .zshrc file with the following: TIMEFMT=$'\nuser\t%*U\nsystem\t%*S\ntotal\...
1
vote
1answer
105 views

How can a shell script know it was invoked on the shell's CLI?

I would like to implement a zsh script that behaves differently depending on whether it was invoked directly on the shell's CLI or not. I thought at first that the script could do this by looking for ...
0
votes
0answers
40 views

How can I introduce a pause during a tmux send-keys operation?

I want to use tmux's send-keys to run a series of commands when I log into a remote server In the linked answer, a single command is used. I've found that I can put a series of them but I've never ...
1
vote
1answer
36 views

Insert newline to the beginning of the command if it's too long

Similar to this question, but instead of adding a new line to the end of the prompt, add a new line to the beginning of the long command (when a command reaches to the right side of the command line ...
1
vote
1answer
56 views

Displaying icons for directories in zsh prompt

This is, roughly, my left prompt for zsh: # Libraries autoload -Uz colors && colors # User color if [ "$(whoami)" = "root" ]; then COLOR="red" elif [ "$(...
1
vote
1answer
58 views

Is there a way to print the commands that the shell builtin `source` is calling when sourcing a script? [duplicate]

sh, bash, etc. have a -x flag that will show you each command that is executing in a script. This is handy for debugging. $ sh -x my_script.sh + case $SOMETHING_DIR in + unset ...
0
votes
1answer
118 views

Zsh autocompletion for function based on git, why is compdef not working in .zshrc?

I have an alias for git defined as alias g=git With this and my zsh and antigen setup, g has the same auto-completion as git. However, when I replace g with a function to show the git status by ...

1
2 3 4 5
50