Questions tagged [zsh]
Zsh is a shell designed for interactive use, although it is also a powerful scripting language.
1,413
questions
0
votes
0
answers
8
views
Touchbar doesn’t work on MacBook Pro (14,2 2017) with Debian install
I downloaded Debian 12 on my MacBook Pro (14,2 2017). I have tried the various reddit/form/blog post and instructions. I am really at my wits end trying to make this work. New to Linux but I know ...
-1
votes
0
answers
57
views
notify when terminal output added
It would be helpful to know if there's a way to get notified e.g. a sound, or better a notification popup, when a line is added to the terminal output.
e.g. while true; do; sleep 5; echo "notify&...
1
vote
0
answers
31
views
Accessing file association information from shell in macOS Sonoma (14.3.1)
macOS used to use a plist at ~/Library/Preferences/com.apple.LaunchServices.plist to store file association information. Recently(ish) that file has moved and is now called ~/Library/Preferences/com....
1
vote
0
answers
26
views
Get last command in error trap in zsh
This function should show the last command when an error has occurred:
TRAPZERR() {
cmd=$_
echo command \'$cmd\' had an error
}
$_ just gives the last argument.
$ false ...
0
votes
0
answers
15
views
using scp or echo in zsh with alias parameter print 'No such file or directory'
here zsh on MacOSX.
I would like to point out that I have tried several ways, with and without quoting, single or double quoting, with and without brackets, with/out $variables. But I receive ever ...
2
votes
1
answer
62
views
How to start tmux as the default when terminals opened exclude the terminal in Dolphin
I want to set tmux as the default when open terminals (eg. Yakuake, Konsole), but exclude the terminal in the Dolphin file-manager.
I put the following snippet in the ~/.zshrc
if [[ -x "$(command ...
1
vote
0
answers
33
views
Zsh handling of substring changed?
I have over a thousand directories holding MP3 files and text. I work on one directory each day, assisted by zsh scripts. I mostly use zsh on command line and in scripts. The paths are in the form ...
1
vote
1
answer
88
views
Default shell zsh but responding bin/bash
I have no idea what I did! I was installing maven and one of the guides had me do something and now I'm stuck in default zsh. I've tried changing my terminal preferences to be /bin/bash, as well as my ...
0
votes
1
answer
69
views
How do I Iterate over an array of spaced string pairs in zsh?
I was reading the post here and tried out the solutions.
However, the following does not produce any output. What am I missing?
arr=( '102 351' '576 324' '427 321' )
for str in "$arr[@]"; ...
0
votes
1
answer
73
views
Make zsh behave like bash for commands without trailing newline
Have a look at the following demo:
[user@host ~]$ zsh
user@host:~/ > echo -n test
user@host:~/ > bash
[user@host ~]$ echo -n test
test[user@host ~]$
echo -n is an example for a command, that ...
0
votes
0
answers
64
views
Cannot activate Python virtual environment from within shell script (zsh)
I cannot activate a Python virtual environment from within a shell script (zsh).
I have tried the following:
#!/bin/zsh
conda create -n myenv python=3.10
conda activate myenv
It sends me the error ...
0
votes
1
answer
55
views
Script to install Anaconda and update conda
I want to write a shell script (zsh) that does the following:
Installs Anaconda via Homebrew.
Adds conda to PATH in .zshrc.
Updates conda base environment.
I have come up with the following solution:...
0
votes
1
answer
171
views
How to automatically load multiple SSH keys on ZSH and PowerLevel10k
I'm trying to have my SSH keys loaded automatically when I start my computer (I'm running Archlinux). At the moment I have to use ssh-add [PATH]. I use ZSH, Oh my ZSH and PowerLevel10k.
Here is my ....
0
votes
0
answers
50
views
How to recursively search for files starting with ".#" under a path in zsh?
In the current working directory, la -a returns,
. .#program 2.py .DS_Store picker.py
.#picker 2.py .#program 3.py hw1 temp.test
.#picker.py .. hw2
I ...
0
votes
0
answers
64
views
Unsure what happening with my terminal but I'm getting a weird response
Whenever I run a python file, (vs code) or even open my terminal on mac I get a warning saying.
/Users/ABC/.zshrc:1: command not found: “alias
/Users/ABC/.zshrc:2: command not found: “alias
/Users/ABC/...
0
votes
2
answers
185
views
How can I write my CPU temperature to a file on an Intel Mac?
I'd like to log my Mac CPU temperature to a disk file in the Mac terminal. I've tried:
sudo powermetrics --samplers smc | grep -i "CPU die temperature" >> cpu_temps.txt
...and:
sudo ...
2
votes
1
answer
51
views
What is the text in the frame header of Terminal on startup?
When I start up a Terminal window on macOS, the following text scrolls by in the frame header:
I recognize a few of my brew'd packages like pyenv in there, as well as some basic posix packages, but I'...
0
votes
1
answer
57
views
ZSH: how to make navigation in command line more bash-like?
I recently installed zsh and really like it but I just don't know how to navigate the command line. Home and End keys do not work and Ctrl-Left Ctrl-Right neither.
I set it to vi mode since I am ...
1
vote
0
answers
30
views
Solutions for organising configuration files across devices and between categories [closed]
As a Linux user, I have a lot of non-GUI applications for which I configure their desired behaviour through config files. One of the troubles I have is that I have multiple devices from which I would ...
0
votes
1
answer
71
views
Strange zsh startup command with "uh oh" spam
I am currently on macOS Sonoma 14.2 (Beta) and have a MacBook Pro 2021 with an M1 Max.
I genuinely have no idea where to start on this problem. Whenever I open up a Terminal, I get this weird spammy ...
1
vote
0
answers
45
views
Why does zsh navigation behave differently in the VS Code terminal vs macOS terminal?
When I am using zsh in the inbuilt VS Code terminal, I can:
a) use the up and down arrow keys to navigate through my command history when typing a command:
zsh command navigation
b) use all arrow keys ...
0
votes
0
answers
74
views
zsh syntax highlighter : Make corresponding parenthesis blink
I'm using the zsh-syntax-highlighting on MacOS (with iTerm2) and wonder whether I can configure it so that, if the cursor is on a parenthesis, the corresponding matching parenthesis on the command ...
0
votes
1
answer
104
views
Adding an empty line between the powerline/prompt line and the output line in ZSH?
I am using p10k, and I haven't seen any option other than
# Add an empty line before each prompt.
typeset -g POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
which that adds a line before the powerline/...
1
vote
1
answer
151
views
Compress each directory to its own Zip file from command line
I have a directory of directories. I want to compress each of them in to its own zip file, keeping the same name.
I don't want it to be recursive, I just want to compress dozens of folders in the same ...
3
votes
0
answers
159
views
Is there a good way to write a shell script compatible with both bash and zsh that addresses array elements?
The fact that bash is 0-indexed and zsh is 1-indexed can cause problems. For example the following will work as intended with bash, but not zsh (PS I am aware that I don't NEED to use an array for ...
0
votes
2
answers
625
views
How can I run a bash script in zsh?
I want to run a script written for bash in zsh.
If I run which bash, I get
/usr/bin/bash
Following this answer I have created the following script
#!/usr/bin/bash
echo 'Hello'
The file hello is in ...
1
vote
1
answer
93
views
!$ not automatic in Kali Linux
Does anybody know how to change the behaviour of !$ in Kali Linux ? Right now, if I reference last argument using !$ I must enter the new command with the last argument instead of executing a new ...
1
vote
0
answers
58
views
Autocomplete filepath or show suggestions when adding file using git in zsh
Let's say following is the output of my git status command.
On branch LG-201
Your branch is up to date with 'origin/LG-201'.
Changes not staged for commit:
(use "git add <file>..." ...
1
vote
0
answers
15
views
unwanted nvm manual printout during shell initialization
I have installed nvm using homebrew, and I have the default .zshrc file:
export NVM_DIR="$HOME/.nvm"
[ -s "$HOMEBREW_PREFIX/opt/nvm/nvm.sh" ] && \. "$HOMEBREW_PREFIX/...
0
votes
0
answers
68
views
Propagating zsh window title through tmux, then ssh, to terminal emulator/window manager
My zsh automatically sets my terminal emulator (kitty)'s window title to my current working directory, or whatever program is currently running within it. However, when I ssh to a remote host and run ...
0
votes
2
answers
54
views
How do i prevent websites from appearing in autocomplete in terminal?
I am running MacOS if it matters
I am new to terminal and work in a lab at my uni, we have a server where we ssh into from our laptops. I am using ZSH as my shell and have no plugins besides git ...
0
votes
0
answers
123
views
Tab completion not working in zsh with custom script to change iTerm profile
I am basically following this (rather dated) gist by Hector Leiva because I want my iTerm color scheme to change when I ssh to specific hosts.
I am using ZSH and oh-my-zsh.
Everything is working (i.e. ...
0
votes
0
answers
202
views
~/.oh-my-zsh/oh-my-zsh.sh:17: parse error near `done'
I am keeping to have this error:
~/.oh-my-zsh/oh-my-zsh.sh:17: parse error near `done'
when I source ~/.zshrc...
This is the file ~/.oh-my-zsh/oh-my-zsh.sh
# ANSI formatting function (\033[<code&...
0
votes
1
answer
92
views
Difference between './file' and 'sh file'
On macOS, in the zsh terminal, I ran the following commands:
cd /tmp
mkdir newdir
cd newdir
touch file1
./file1
The last command returned
zsh: permission denied: ./file1
But running
sh file1
executed ...
1
vote
1
answer
374
views
zsh tab-completion for filenames works for some commands, but not others
I wrote a little shell script that lives in the current directory and I invoke it like this: ./import <command> <file>. When I try using tab to complete the filename, zsh just beeps at me.
...
0
votes
0
answers
78
views
Is there a best way to export from the Directory Utility?
I want to export all of the data from a page in the MacOS directory utility. In the edit section, it say's I'm looking at Users in node /Active Directory/XXXXX/All Domains. It lists all the users I ...
2
votes
1
answer
64
views
Change argument to -y, --yes, --assume-yes
Can anyone help me alter this script to automatically YES? y?
I don't need to or want to confirm yes, I just want to pass yes into the shell shortcut.
cat << "EOF" >> ~/.zshrc
...
0
votes
0
answers
101
views
Trouble using dscl to create and add user to group
I am working on a fix for a piece of software where the provider suggests we should create a user group with dscl and then grant the group ownership of a folder.
Users in our environment are on macOS ...
3
votes
0
answers
233
views
How to shorten directory names in git branches with Powerlevel10k?
I’m using the Powerlevel10k theme for ZSH and I’ve set POWERLEVEL9K_SHORTEN_DIR_LENGTH=1 to shorten all directory names except for the current one. This works as expected: [~/Desktop/Codes/...
0
votes
1
answer
65
views
zsh on MacOS catalina 10.15.17
I'm having a little trouble putting this all together...
I want to make a simple shell script to organize and sort around 60 GB worth of music and movie files that are spread out over 3 or for 4 ...
0
votes
0
answers
121
views
Configure zsh syntax highlighting for bash-my-aws
I have been using zsh syntax highlighter from this repo and it has been very great so far. Now, I discovered a repo called bash-my-aws which aliases my awscli commands to a more usable and compact ...
1
vote
2
answers
455
views
How to change folder separator and ~ character in p10k command line
In powerlevel10k (zsh) the path to branch separator can be a triangle or semicircle (bottom in image); in powerline (top of image), the "triangles" can separate also folder/subfolder instead ...
1
vote
0
answers
169
views
Source multiple files in background/parallel (ZSH)
For various reasons I would like to be able to source a series of files in background and wait for them all to finish:
source ./my_file_1.sh &
source ./my_file_2.sh &
...
# etc
wait
But, ...
0
votes
1
answer
252
views
gnome-terminal does not display UTF-8 characters correctly (zsh)
I installed zsh v5.8.1 on Ubuntu 22.04.3. And my gnome-terminal looks like so:
the symboles do not seem to be right. Whats wrong?
1
vote
1
answer
79
views
Correct way to end ssh tunnel
I frequently need to connect to a database instance on AWS, so I use an SSH tunnel. I can create one with the following command:
ssh -N -L 12345:some-database.rds.amazonaws.com:5432 admin@bastion....
1
vote
0
answers
135
views
How to `zcompile` global (system-wide) zsh scripts?
For my local dotfiles I have this snippet at the end of my .zshrc:
for f in ~/.zshrc ~/.zshenv ; do
[ "${f}"(:A) -ot "$f".zwc ] || zcompile "$f"
done
This ensures ...
1
vote
0
answers
71
views
Zsh zle function segfaults on `trap 'zle reset-prompt' EXIT`
I have the following function to select a tmux session with fzf:
function tmx {
[ -n "$ZLE_STATE" ] && trap 'zle reset-prompt' EXIT
local tmux item
tmux="$(which ...
1
vote
1
answer
180
views
iTerm 2 ZSH font all one color
Related to
iTerm 2 ZSH colors/themes not showed correctly
Machine: macOS Ventura 13.3
My iTerm2 wont use any other colors than all white (and all black in vim) for my fonts. Can anyone see what I'm ...
3
votes
1
answer
110
views
Bash read -e -i "Test" needs to be in Zsh
What is zsh equivalent for :
read -e -i "This is pre written text " t
get user into readline with a pre written text ready to edit an save
to a variable ?
0
votes
1
answer
715
views
How to get kube-ps1 working in the Warp terminal on MacOSX?
I'm trying to move from iterm2 to warp, but one thing that I can't get working, which is quite crucial for me, is the kube-ps1 project. What it does is to make the current Kubernetes context visible ...