Questions tagged [zsh]
Zsh is a shell with many advanced command-line and scripting features.
2,857
questions
1
vote
1
answer
32
views
Oh my zsh is only working when i log in as root
Recently installed zsh and oh my zsh but when i open a terminal nothing changes, the bar keeps looking as always but it changes only when i log as root doing sudo su, I have tried almost everyting but ...
2
votes
1
answer
34
views
zsh gnu-screen tab completion for `-x` flag similar to `-ls`
In bash, when I type screen -x and press tab twice, I get a list of all the running sessions.
In zsh, when I type screen -ls and press tab twice, I get a list of all the running sessions and can tab ...
0
votes
0
answers
19
views
Different methods of calling "display dialog" - BASH/ZSH/AppleScript
I noticed that I use 2 different ways to call display dialog in my BASH and ZSH scripts.
osascript -e 'set dialogText to text returned of ¬
(display dialog ¬
"Insert Text" ¬
with title "...
2
votes
1
answer
31
views
How to select the whole buffer by using zle widget?
I have a zle widget like:
_ctrl-a() {
CURSOR=0
if ((MARK == 0)); then
zle set-mark-command
fi
if [ "$BUFFERLINES" -gt 1 ]; then
zle end-of-buffer-or-history
else
zle ...
1
vote
1
answer
33
views
How can I find the source code of builtin zsh widgets (zle)?
Where are builtin zle widgets stored? I am trying to find the code for beginning-of-buffer-or-history and beginning-of-line. zle -al output shows these exist in my machine.
I have ran:
% echo $widgets[...
1
vote
1
answer
59
views
Shell Variable Expansion in qsub command through drmaa
I am running a bulk job submission to SGE (Sun Grid Engine) using python drmaa bindings.
For the bulk job submission I am submitting a python script that takes in one argument and is command line ...
0
votes
1
answer
26
views
How can I remove specified terms from filename when reading list?
I am at the very beginning of this phase of a personal project. I have a large number of video files liberally strewn with terms like "1980p", "webrip" and such that I would like ...
0
votes
1
answer
35
views
.desktop file stopped working after changing default shell from bash to zsh
i have been using this desktop file pluto.desktop:
[Desktop Entry]
Exec=/home/user/Software/Installed/Pluto/pluto_startup.sh
Icon=/home/user/Software/Installed/Pluto/Pluto.svg
Type=Application
...
3
votes
1
answer
101
views
Zsh - What is this Cool Thing called you get by pressing Tab after "("
Short Version
If you press tab after the following command you get a filer-menu. What is the name of it?
ls *(
Long Version
I just doing my linux-stuff and by accident I pressed tab after ( and a ...
0
votes
1
answer
22
views
ZSH alias to grep all aliases stopped working
This worked for me for ~8 years:
$ alias al='alias | grep $1'
Example:
$ al git
clean='git clean -xfde'
echo_git_root='echo "$(git rev-parse --show-toplevel || echo .)"'
# etc.
I could ...
0
votes
1
answer
57
views
Zsh i named variable; "bad math expression: operand expected at `/houdi/loo...'"
this's quite puzzling me, doing Zsh assignment using variable namedly i
% for i in '/houdi/lookup' '/komando/' ;{ echo value i = "$i" }
zsh: bad math expression: operand expected at `/houdi/...
1
vote
2
answers
23
views
bindkey commands run in .zshrc seem ignored when in tmux
I have some bindkey commands in my .zshrc file which behave as desired.
I start tmux; the same .zshrc is run, including the bindkeys but they don't function.
But then if I manually type them on the ...
-3
votes
1
answer
35
views
Bash variable ${DIRSTACK[@]} for zsh
What the Zsh equivalent of Bash's ${DIRSTACK[@]} variable?
0
votes
1
answer
39
views
Comments are causing errors after changing the value of "histchars" in zsh
Why, after using set histchars='?', is there an error that occurs every time I source ~/.zshrc?
/home/user/.zshrc:1: bad pattern: #
In other words, every # token within comments is causing some ...
0
votes
0
answers
55
views
how to restore stdout? [closed]
I'm not exactly sure how it happened, but cat in my zshell session is no longer working
I think it may have happened when I tried piping some output to an anonymous function, but I'm not sure, and don'...
0
votes
1
answer
26
views
Zsh bindkey map Ctrl+c To Ctrl+p
I know how to map CTRL+L to run a command like 'ls'
bindkey -s "^L" 'ls^M'
but how can I map CTRL+c to another key stroke like CTRL+p in my ZSH?
Or what is the command to kill the current ...
0
votes
0
answers
37
views
Zsh command history completion
How to have case insensitive in retrieving completion of command history in Zsh ?
did put setopt NOCASEGLOB in ~/.zshrc but has nothing for help
how is the correct way to do?
3
votes
2
answers
76
views
Where is 'command' finding my command?
I have a shell function that looks like this:
rebar3 () {
set -o localoptions -o localtraps
trap '/bin/stty sane' INT
command rebar3 "$@"
}
How do I find out where command ...
1
vote
1
answer
48
views
Zsh do utilities distinction
How do Zsh distinguish utility/file if it's executable either binary or script, or just file, or shell builtin, etc, etc ?
2
votes
3
answers
37
views
Confusing pushd/popd behaviour when sourcing script in zsh
I have a script which I source while in bash. It does various things and retains the $PWD I was in before sourcing it.
pushd ~/.dotfiles >/dev/null || exit 1
# Do various things
popd >/dev/...
-1
votes
1
answer
39
views
Can a bash script add to the context of zsh?
I have recently migrated from bash to zsh.
I used to use the following token_refresh.sh script to ssh-add my private key to the session:
#!/usr/bin/env bash
echo "configuring ssh access.."
...
-1
votes
1
answer
23
views
Zsh string variable containing multi words must be assigned to an array
How to have Zsh string variable containing multi words separated by space be assigned to an array so that each word is the array element
s='run help behind me'
a=($s)
m=${a[0]}
n=${a[1]}
print "m=...
0
votes
1
answer
34
views
zsh: alias'd commands stop working
This keeps happening and I'm not sure why. How do I trace what zsh is actually trying to do, and why it starts ignoring my alias?
************@*******-MacBook-Pro$ reload
zsh: command not found: ...
1
vote
1
answer
78
views
Ideas for why PATH has these directories
In my .profile I have PATH="$HOME/.local/lib:$HOME/.local/bin:$HOME/.node_modules/bin:$HOME/.cargo/bin:$HOME/local/bin:/usr/bin:$PATH"
In my .zshrc I have miniconda path stuff (export PATH=&...
-2
votes
1
answer
43
views
Get help for zsh builtin command (--help' does not work)
Why, unlike Bash, almost all Zsh executable's option of '--help' cannot work, what'd be its counterpart to help user doing on it ?
0
votes
1
answer
20
views
Command line "delete last word" misbehaving
In my zsh environment, when I try to delete last word on command line using either Ctrl + W or Opt + Delete, it is always misbehaving, eg
# start with this line below
pg_ctl --help
# Trying to delete ...
7
votes
2
answers
790
views
Echoing "!" inside a string does some weird things [duplicate]
If I type in this:
echo "Hello, World!"
I don't know the name of it, but it prompts me for the next line. You know the PS2 thing. Or if you type echo \ and press Enter.
Why?
Well I know ...
0
votes
2
answers
39
views
Edit PATH variable content
When I type python3 on my zsh terminal, Python 3.9 gets launched:
Python 3.9.0 (v3.9.0:9cf6752276, Oct 5 2020, 11:29:23)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright&...
5
votes
2
answers
912
views
Source not working the same way for bash as for zsh, cannot forward source commands as expected
I have been using bash at work and zsh at home, different macbooks. I know very little bash or zsh scripting, so I didn't dare do the switch until I managed to get my ZSH on par with what I had at ...
4
votes
1
answer
351
views
How to use argument twice in printf in shell?
printf %s%s one two prints onetwo but I would like oneonetwotwo
How can I do that?
1
vote
1
answer
39
views
loaded run-help function code doesn't match its actual source code from disk
From the beginning of installing zsh, run-help was opening a man page (one of zsh sections) for the commands like typeset, autoload. Recently, I looked up the function source code at /usr/share/zsh/...
0
votes
1
answer
47
views
cp command asking for confirmation of overwrite even with -f switch (zsh)
I have the following in a file which is sourced from ~/.zshrc:
# Starship prompt
cp -f ~/.config/starship.toml ~/.config/starship-zsh.toml
export STARSHIP_CONFIG="$HOME/.config/starship-zsh.toml&...
2
votes
1
answer
37
views
Alias + and - in zsh?
For years I've used + and - as aliases for pushd and popd in both csh and bash. I've finally given up on my Macs and want to switch to zsh but I haven't been able to find a way to make these aliases. ...
2
votes
1
answer
72
views
Oh-my-zsh deletes output of successful command with "FAIL: 141"
My Oh-my-zsh does the following:
When I run the git log --pretty --oneline command, it shows me a long list of commits, as expected.
As soon as I hit q, it suddenly disappears with the below output:
...
3
votes
3
answers
401
views
in zsh, strip and add a suffix in a single glob pattern
Suppose I have a file named foo.md.md (the reason for the double suffix will become apparent).
$ print *.md(om[1]) # Get the most recent .md file
foo.md.md
$ print *.md(om[1]:r) # Strip the suffix
...
0
votes
0
answers
44
views
Compress list of files as their shortest exclusive glob
How can I convert a list of files to the minimum-length glob that expands to those files and no others?
E.g. in a directory
root
├── one
└── two
Then the list root/one:root/two can be converted to ...
0
votes
0
answers
21
views
Insert into the shell a filepath used from a previous command [duplicate]
I have a series of commands like
$ touch path/to/file.cc
$ less path/to/file.cc
...
and in the second command I'd like to automatically insert the path used in the previous command. Is there a way to ...
2
votes
2
answers
251
views
zsh: How to change the color of all invisible file names in the Mac's Terminal?
I'm using a Mac Silicon with the Ventura MacOS. In the Terminal app, all the file names have the same color. Take note that the default shell is zsh in Ventura, and is the one I want to use. ...
7
votes
1
answer
1k
views
mv: rename <oldname> to <newname>/<oldname>: Invalid argument
On my TrueNAS (FreeBSD 13.1) server I have a directory named OldHDD which I want to rename, but I get an error:
% mv OldHDD oldhdd
mv: rename OldHDD to oldhdd/OldHDD: Invalid argument
I have tried ...
0
votes
1
answer
523
views
/dev/fd/12:18: command not found: compdef
I am new to coding and using the terminal, but after installing Angular, this keeps popping 3 times on my hyper terminal, even after i was told to to do this :
to fix that, in your terminal type: ...
0
votes
0
answers
71
views
How do I change an oh-my-zsh bindkey that a plug-in set?
You can find most of the context on this github comment. I installed the zsh-autocomplete plugin and it adds a feature I don't want: pressing up fills the page with a menu of previous commands I've ...
0
votes
2
answers
77
views
Split large plaintext file into smaller ones on the last whitespace before each 2000th character
Requirement: BSD versions of tools not GNU.
I have a ZSH script that scrapes a weekly newsletter from a website, grabs the main section, converts it into plain text, and saves it to a file. It then ...
1
vote
0
answers
175
views
Unable to import tensorflow_datasets ("not a mach-o file")
I have just set up my Mac M1 environment for tensorflow, and it seems to be running fine, the issue I'm having is setting up tensorflow_datasets. I installed this by running this in my conda env:
...
1
vote
0
answers
41
views
How do I prevent zsh from expanding shell history when I press space?
I can reproduce this issue on cygwin and Ubuntu wsl's oh-my-zsh shell, but my bash shell works the way I want. My intent is to run these two lines on the command line:
npm rm plugin-alias
npm i -D ...
2
votes
1
answer
62
views
zsh completion: complete --options for custom script
I have zsh completion rule for custom script. My script can take zero or more options (starting with -) and zero or more arbitrary strings (patterns):
_arguments -S : \
'--foo' \
'--bar' \
...
3
votes
2
answers
108
views
How can I save a text file with all command line inputs and outputs without saving the ANSI characters?
I am running the latest mac OS and using zshell, and having trouble writing a shell script. I do most of my work from the command line, and wanted to have a bash script automatically save and log all ...
0
votes
0
answers
39
views
zsh vared: how to define custom completion?
I would like to launch a command that would read user input and pass each line as a new task to TaskWarrior:
#!/bin/zsh
set -e
while vared -p 'task add> ' -eca task; do eval task add "${task[@...
0
votes
1
answer
30
views
What is the EPS1 environment variable used in zsh prompts?
Many zsh configs floating around the internet that set the right-hand prompt RPS1 append the value of EPS1 to the end, but I have found no documentation anywhere of what EPS1 might contain. On my ...
0
votes
1
answer
91
views
Why does opening new zsh terminal print environment vars [closed]
Each time I open a new terminal in Mac OS, it prints a selection (but not all) of my environment vars. I use zsh shell. e.g
HOME=/Users/xxxx
LANG=en_GB.UTF-8
LESS=-R
LOGNAME=xxxx
LSCOLORS=...
2
votes
0
answers
23
views
zsh: don't remember certain commands [duplicate]
I use zsh and oh-my-zsh. Whenever I use a command that has rm -rf, or a command that starts with space, I want it to not be saved in the shell history. Is that possible?