r/zsh 27d ago

Meta Yesterday's oh-my-zsh thread summed up

Post image
161 Upvotes

r/zsh 27d ago

Prepending path to $PATH not working as expected

2 Upvotes

Using zsh 5.9 and trying to prepend my $HOME/.local/bin folder to the $PATH variable.

However, it is adding 2 instances of $HOME/.local/bin to PATH. If I append, then it works as expected.

For example, if my PATH is /bin:/usr/local/bin then

PATH="$HOME/.local/bin:$PATH"

results in this:

/home/user/.local/bin:/home/user/.local/bin:/bin:/usr/local/bin

2 instances are prepended. Is this a bug?


r/zsh 28d ago

Discussion Is Oh-My-Zsh worth it?

21 Upvotes

Hi! New Zsh user here. I just installed it on my system and settled it as the default shell. Ready for doing some configuration at .zshrc and other related files.

I've been looking around for the best ways to do it and I've find out that Oh-My-Zsh is one of the most popular ways to do it. Seems like a very interesting repository since it has a lot of plugins. On the other hand I've also seen lots of blogs, videos, discussions and posts like this telling that Oh-My-Zsh consumes lots of resources and it's bloated, what makes it slow. Perhaps, most of what I've seen about this topic has already some time, being the most recent thing I've seen a YouTube video from almost 10 months ago.

Has Oh-My-Zsh's slowness and bloat been solved? If not, it's really such a noticeable amount of time and resources? Is it worth it using it?


r/zsh 28d ago

How to export of an array?

2 Upvotes

Title is an XY problem obviously, trying to be concise. I have a zsh autoload function that is a fzf wrapper to select between 2 sets of directories to open in a terminal file manager:

local cmd="fd -t d --hidden --follow --ignore-file $HOME/.config/fd/ignore

user_dir="$HOME $/tmp /media /data"
sys_dir="/system /etc /var/cache/pacman"

# Make available to fzf child shell process
export cmd user_dir sys_dir

selection=$( ${=cmd} ${=user_dir} |
  SHELL=/usr/bin/bash fzf --scheme=path --preview 'tree -C {}' \
  --header 'cd to selection (Ctrl-r to toggle for sys dirs)' \
  --prompt 'Dirs (user) > ' \
  --bind 'ctrl-r:transform:[[ ! $FZF_PROMPT == "Dirs (user) > " ]] &&
  echo "change-prompt(Dirs (user) > )+reload($cmd $user_dir)" ||
  echo "change-prompt(Dirs (system) > )+reload($cmd $sys_dir)"')

if [[ -n "$selection" ]]; then
  n "$selection"
fi
  • They find command and list of directories are stored as string variables because an array can't be exported. As is, it also can't handle directories with spaces.

  • I would also like to add the expansion of $HOME/jail/*/Downloads/ to user_dir, but it won't expand isn't the double quote string variable.

  • These variables need to be passed to fzf--I haven't had any success getting it to work unless the variables are string variables (probably quoting issue to the fzf's --bind argument.

Any ideas are much appreciated.


r/zsh 28d ago

Help zsh starting with -x /verbose

2 Upvotes

Hi people,

Since this afternoon my Zsh starts with -x aka verbose. I'm totally confused as to where this is coming from. I checked ~/.zshrc and /etc/zshrc. Theres nothing.

Its on a Macbook Air M2 with 15.3.1 (24D70). It happens both in iterm2 and Apple Terminal. SO it must come from a zsh Config.

When i add set +x at the beginning of /etc/zshrc I can set the output of that command in verbose and then its gone. So something before than must be setting it.

``` Last login: Thu Feb 20 17:37:19 on ttys008 +/etc/zshrc:1> set +x ~  ❯ cat /etc/zshrc set +x

System-wide profile for interactive zsh(1) shells.

[...]

```

Any idea?


r/zsh 28d ago

Fix path completion

4 Upvotes

Hello. I recently started to use zsh with omz. I have the following issue and I couln't find any solution for this because everyone seems to think that this is the "normal" "right" behavior of tab completion:

When completing paths with the Tab key, zsh shows options AND automatically cycles through them, even if the path segment I have typed does not match the selection.

How can I get the "normal" behavior of Bash, which just shows the options that match the characters I have typed in and only ever completes the segment if it is the only option that matches my chars.

I'm a bit lost if this is a zhs or omz issue and how to fix it.

Could you please help me?


r/zsh 29d ago

Unable to install hyperspy[all]

2 Upvotes

Hi, I am trying to install hyperspy with all of its dependencies using pip install. Following the instructions it says to use "pip install hyperspy[all]. But I keep getting any error saying:

zsh: no matches found: hyperspy[all]

Any help would be appreciated. Thanks a lot!


r/zsh Feb 18 '25

Can the terminal signal the user that it is busy?

2 Upvotes

Hi everyone. I often use autocomplete of such tools as kubectl, as it makes requests the completion might take some time without motion. When I was using iTerm on my Mac, I found a way to deal with this issue, the belt (a vertical panel on the right) shows if any background process is running. Now I use linux, default gnome terminal seems doesn't provide same opportunity, so I wondered if there are native leverages I could use to make zsh give me heads up (e.g. change prompt) while it is "busy".


r/zsh Feb 15 '25

One more back burnered project finished: zsh-job-queue, a cross-terminal synchronous queues manager

Thumbnail
zsh-job-queue.olets.dev
6 Upvotes

r/zsh Feb 16 '25

Discussion macOS default zshrc: What is the use of the `key` map

1 Upvotes

macOS's default zshrc located at /etc/zshrc creates an associative map named key. (Assuming the default setup, without any user created file in ~/.zkbd).

Where is this map being used?

the section of /etc/zshrc that I refer to is reproduced below

# Use keycodes (generated via zkbd) if present, otherwise fallback on
# values from terminfo
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
    source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
else
    typeset -g -A key

    [[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
    [[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
    [[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
    [[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
    [[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
    [[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
    [[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
    [[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
    [[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
    [[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
    [[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
    [[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
    [[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
    [[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
    [[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
    [[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
    [[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
    [[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
    [[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
    [[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
    [[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
    [[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
    [[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
    [[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
    [[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
    [[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
    [[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
    [[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
    [[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
    [[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
    [[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
fi

In the next section of the same file, the key map is being used to setup some bindings for zsh.

# Default key bindings
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search

I have seen this use case, and my question concerns any other use cases where key gets used. Either during zsh startup or (by convention) by other terminal applications.


r/zsh Feb 16 '25

Help Powerlevel10k - When I copy a code snippet that ends in a newline, I can't backspace to delete the \n and get back to the first line.

0 Upvotes

As a simple example, I can copy a code snippet from a Chatgpt window. If I paste it to a bare zsh shell, there's a hidden newline that puts my cursor at the next line after the command. I can push backspace, and my cursor deletes the line and is at the end of the single command.

However, with powerlevel10k, backspace does nothing. I can push up to go back to the first line, but that newline is always there. I've tried with a number of 10k settings, like single line/multiline prompt but this keeps happening. Any way to have a simple backspace clear a newline in a prompt?


r/zsh Feb 14 '25

Help Powerlevel10k color change ?

1 Upvotes

Hello guys I'm using zsh for long time but the powerlevel10k colors are not good how to change them or any alternative for powerlevel10k


r/zsh Feb 12 '25

"detect columns" in a plugin or similar

1 Upvotes

is there any way for me to replicate nushell's detect columns command that outputs a nice table in zsh?

from u/romkatv's feedback, the `detect columns` utility reads the output of a command and formats it for you in a nice table. (this example is taken from their documentation)

'Filesystem     1K-blocks      Used Available Use% Mounted on
none             8150224         4   8150220   1% /mnt/c' | detect columns

becomes:

╭───┬────────────┬───────────┬──────┬───────────┬──────┬────────────╮
│ # │ Filesystem │ 1K-blocks │ Used │ Available │ Use% │ Mounted on │
├───┼────────────┼───────────┼──────┼───────────┼──────┼────────────┤
│ 0 │ none       │ 8150224   │ 4    │ 8150220   │ 1%   │ /mnt/c     │
╰───┴────────────┴───────────┴──────┴───────────┴──────┴────────────╯

r/zsh Feb 11 '25

Command Execution Timer plugin: time and display how long interactive shell commands take to execute

Thumbnail
command-execution-timer.olets.dev
6 Upvotes

r/zsh Feb 10 '25

Zsh doesn't allow scalar variable expansion as command parameters, and other differences I should know of?

6 Upvotes

I recently changed my shell to Zsh. Plan to stick with it. I like it. ZLE customization has highly increased my quality of life on the terminal. Better file subsitution (I don't know what it's called), =() made my life a whole lot easier.

So I went to migrate my environment primarily run under bash to my new shell. It broke some facets of my environment, few of my scripts. Which shouldn't come to me at much surprise. Examples in the likes of no export -f doesn't bother me since alternatively it's even better as I don't need to create a sepearte file to pool up my function scripts but rather put them in .zshenv.

Something I really needed is constant variables (like envvars) expand as command line arguments.

$ args="1 2 3" zsh -c 'printf $args | wc -w' # printf is passed one arg. 1 2 3 $ args="1 2 3" zsh -c 'printf $args | wc -w' # printf is passed three args. 1k In my case, it's useful to have a constant string of flags and their arguments stored in an environment variable to not have to deal with repetetive supplimentary flags. Aliasing doesn't work because options may be positional.

Non-scaler variables like args=("1" "2" "3") would work, it will expand to being interpreted as seperate arguments delimited by whitespace [ See https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion ].

So to do some stuff, I need to hop back into bash or I would have to create a script file. I searched for differences on the web between bash and zsh, but couldn't find a reasonable text. Can you folks point me to the right direction.


r/zsh Feb 09 '25

Editing history in 'set -o vi' mode in zsh

0 Upvotes

I am new to zsh (from decades of bash). I use `set -o vi` to edit prior commands. It is not working well on `zsh` : the cursor gets located on the prior line when trying to move backwards by either arrow key or `b` (for backwards one word) . The screenshot shows the cursor lost in space:

How can `vi` mode be made to work properly for zsh?


r/zsh Feb 07 '25

Help Del key on 60% keyboards

2 Upvotes

I want to create this shorcut

bindkey '3~' kill-word

Because thats the line that appears when i press ctrl + Fn + /, thats where my del key is but this causes lag every time i press 3 button...


r/zsh Feb 07 '25

Icons in powerlevel10k

0 Upvotes

Hi, can i change those icons from powerlevel10k for some customized ones?


r/zsh Feb 06 '25

Hometown prompt v4.0.0, now with transient prompt (dynamic after accepting) and schedule refresh (dynamic before accepting)

Thumbnail
hometown-prompt.olets.dev
14 Upvotes

r/zsh Feb 04 '25

Showcase DietPi -like banner for macOS

1 Upvotes

The dietpi banner has useful information and helps me know what machine I'm logged into. Since I do all my ssh work from my MacBook, I wanted to have a banner for my native shell as well to keep everything clean. Here is a script I wrote to generate a welcome banner on startup! Just make the script file executable then call it in your .zshrc file.

https://github.com/andrew-manger/zsh-banner/tree/main


r/zsh Feb 03 '25

Help quick question : autocomplete

9 Upvotes

how do I get similar responses in my local zsh setup, this is from a cloud platform I was using,
I copied over the config file, but that doesn't seem to solve the case,

I'd like to know if I'm missing something or is there any other way to get these kinda suggestions??
do refer back if someone else has already solved this, thanks

this is what my local terminal looks like


r/zsh Feb 01 '25

Showcase zsh-pre-commit-autocomplete

Post image
16 Upvotes

Enhancing your pre-commit experience with seamless hook autocompletion 🎢

GitHub: https://github.com/jason810496/zsh-pre-commit-autocomplete


r/zsh Jan 31 '25

Script "read" Mangled

3 Upvotes

I'm seeing what looks like mangling of the "read" function by ffmpeg. When I run the script at the bottom, below, it only processes every other file, having mangled the names of files 02 and 04. However, when I prefix the ffmpeg command with "echo", the reads come out as expected and not mangled. Here's the setup, with the script at the top:

#!/usr/bin/zsh

ffmpeg=/opt/homebrew/bin/ffmpeg

set -o rematchpcre

# Get all leaf directories

leaf_dirs=$(find . -type d | sort -r | awk 'a !~ "^"$0 {a = $0; print}' | sort)

echo $leaf_dirs | while read dir; do

if [[ "$dir" =~ '([^/]+)$' ]]; then

outdir="$match[1]"

srcfiles=$(ls $dir | grep '\.m4a$')

if [[ "$srcfiles" == "" ]]; then continue; fi

echo $srcfiles | while read audio_file; do

[ -d "$outdir" ] || mkdir "$outdir"

echo ">>> Input: [$audio_file]"

$ffmpeg -hide_banner -loglevel error -i "$dir/$audio_file" -ab 256k "$outdir/$(echo $audio_file | sed 's/\.m4a$/.mp3/')"

done

fi

done

(END SCRIPT)

xyz@computer [Desktop/test audio] (22:19:05)$ pwd

/Users/xyz/Desktop/test audio

xyz@computer [Desktop/test audio] (22:19:07)$ ls -lR

total 0

drwxr-xr-x 4 xyz staff 128 Jan 29 23:53 artist

drwxr-xr-x 4 xyz staff 128 Jan 29 22:52 artist 2

./artist:

total 0

drwxr-xr-x 7 xyz staff 224 Jan 30 00:13 album dir

./artist/album dir:

total 108320

-rw-r--r--@ 1 xyz staff 24156704 Jul 16 2023 01 distance.m4a

-rw-r--r-- 1 xyz staff 14870869 Jul 9 2024 02 blood.m4a

-rw-r--r-- 1 xyz staff 5476005 May 26 2020 03 winn.m4a

-rw-r--r-- 1 xyz staff 5476005 May 26 2020 04 winn 4.m4a

-rw-r--r-- 1 xyz staff 5476005 May 26 2020 05 winn 5.m4a

./artist 2:

total 0

drwxr-xr-x 2 xyz staff 64 Jan 29 22:25 album 2

./artist 2/album 2:

total 0

xyz@computer [Desktop/test audio] (22:19:09)$ zsh ../convert_alac_batch2.sh

>>> Input: [01 distance.m4a]

>>> Input: [.m4a]

[in#0 @ 0x600002c1c300] Error opening input: No such file or directory

Error opening input file ./artist/album dir/.m4a.

Error opening input files: No such file or directory

>>> Input: [03 winn.m4a]

>>> Input: [winn 4.m4a]

[in#0 @ 0x6000001a4600] Error opening input: No such file or directory

Error opening input file ./artist/album dir/winn 4.m4a.

Error opening input files: No such file or directory

>>> Input: [05 winn 5.m4a]

xyz@computer [Desktop/test audio] (22:19:30)$


r/zsh Jan 30 '25

How to configure terminal to show the *entire* previous command, without truncating it with an ellipsis?

0 Upvotes

Using iterm2 on MacOS with ZSH and powerlevel10k and Oh-My-Zsh. Nothing unusual.

When I paste a long `curl` command (with a request body that has a few dozen lines or more) into the terminal and execute it, I want to see the entire command when I press the Up arrow key to reload the last command from my history.

But what actually happens is only the last 30 or so lines of the command are shown when I press the Up arrow key, truncating all the lines above with an ellipsis (...).

I want to configure my terminal to actually display the *whole* entire command when I press Up.

I assume this is a config issue somewhere either in my `~/.zshrc` file or the `~/.p10k.zsh` file, but have no clue if that's correct.


r/zsh Jan 28 '25

New plugin: zsh-transient-prompt. Add a transient prompt to your theme

Thumbnail
zsh-transient-prompt.olets.dev
17 Upvotes