All Questions
319
questions
1
vote
1
answer
54
views
Why I can't change the prompt in VSCode's terminal?
I am trying to change the prompt in my VSCode's terminal.
My OS is MacOS Monterey 12.6.
I use the zsh and I change the PS1 in .zprofile,such like this.
Then I use echo to test.The others can work ...
1
vote
1
answer
328
views
Complete overview of Bash and Zsh startup files sourcing order
I was confused in what order my shells source which files. When researching this for myself, I came across several sources online and even read some parts of the manuals for both shells. But still, ...
1
vote
1
answer
325
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
169
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
138
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 ...
3
votes
0
answers
222
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
1
answer
101
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 ...
0
votes
0
answers
118
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 ...
0
votes
1
answer
73
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 ...
1
vote
0
answers
381
views
How to have Zsh completion menu and use glob patterns + recursive search?
I have the following setup for zsh completion
autoload -U compinit && compinit
zstyle ':completion:*' menu select
zstyle ':completion:*' complete-options true
setopt GLOB_COMPLETE
zstyle ':...
0
votes
1
answer
313
views
How to remove Anaconda PATH?
I have uninstalled Anaconda from MacOS but still there is on the PATH. I have searched all .bash_profile, .zshrc but I did not find anywhere that set the Anaconda path.
It is available on both bash ...
0
votes
0
answers
102
views
How do Linux terminal programs set up the environment for the shell program
I am writing a terminal emulator in Rust. The source is here. It forks itself and the child process (eventually) becomes the shell program which it reads output from and passes input to.
On macOS, ...
1
vote
2
answers
2k
views
Bind command not found in Linux Mint/Ubuntu terminal
I need to use this "bind" command described in articles like:
https://www.computerhope.com/unix/bash/bind.htm
https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html#Bash-...
0
votes
1
answer
51
views
I'm not sure how to insert "path to this file" in a source command. I want to forward source commands without using a hardcoded fully qualified path
What I'm trying to do should be simple. Yet it's just not working.
I have a repo with my dot files. I want to be able to clone this repo anywhere in my system, and just source one single file. I then ...
0
votes
1
answer
65
views
Streaming outputs to another window without running the same commands again on iterm2
First of all, I think every command running consumes some resources.
So if I'd like to have another window displaying the same output of the same commands being run on another session without running ...
1
vote
1
answer
10k
views
zsh: event not found: /bin/bash
When I run the following on my command line #!/bin/bash I get the error zsh: event not found: /bin/bash.
I'm on Mac Ventura.
If I run zsh the command works fine, so the issue is with /bin/bash.
Does ...
0
votes
0
answers
1k
views
MobaXterm builtin shell (zsh/bash 64bit) strange behavoiur
Using builtin terminal from MobaXterm, and executing commands like curl or ssh works couple of times and later produce no output at all. Anyone had similar experience? My problems started after ...
0
votes
0
answers
434
views
-bash: command not found in macOS 12.6.3. How can I fix this?
I am a new to macOS and I am using an the iMac running macOS 12.6.3 (Monterey) I am trying to load pygame.
I have already loaded python 3.11 and pycharm. Every time I try to load pygame I keep ...
0
votes
2
answers
528
views
How to copy output from a zsh terminal using vi movements(or if that's not possible any other way)?
Currently I am using vi motions in zsh and it is incredible. I work on terminal a lot and it is annoying to switch back to move to copy an output. Is there a way to use vi motions or anything else to ...
4
votes
1
answer
606
views
Possible to get Bash like tab completion in ZSH?
If you do the following in Bash
$ touch b bb bbb
$ ls b* # press tab twice
b bb bbb
If you do the same in ZSH you get
➜ ls b bb bbb
ZSH expand the matches to the command and hence removes ...
1
vote
0
answers
54
views
$RANDOM, not so random [duplicate]
I want to print out a random number and encrypt it, like so: echo $RANDOM | sha256sum.
I would expect this to take the standard output of echo $RANDOM and pipe it into the encryption function. However ...
4
votes
3
answers
2k
views
Copying a path in the terminal with the keyboard
I often find that when using the command line, I need to copy a path that appears in the output of the last command. For example I might use find . | grep like this:
[user@localhost /tmp]$ find . | ...
0
votes
0
answers
589
views
Ubuntu 22 - zsh: command not found: lessc
OS: Ubuntu 22.04.1 LTS
zsh 5.8.1 (x86_64-ubuntu-linux-gnu)
Before installing oh-my-zsh everything worked, now I have issues.
One of the issues is zsh: command not found: lessc, but who knows how many ...
0
votes
1
answer
1k
views
Get output logs of previous command in ZSH
I'm working on a helper script that needs to run after every command to analyze its exit status and output logs.
I understand that stdout/stderr buffers are not stored on pseudo terminals. I therefore ...
1
vote
0
answers
571
views
Passing flags to a command inside an alias
I have created an alias for ls in order to let it print out a format that I like. I have defined the following alias to do this:
alias ls="ls -lo --color=always | awk '{if (NR != 1) {print \$8,\$...
0
votes
1
answer
877
views
Most effective way to add custom script to /bin? & best practices
Most effective way to add custom script to /bin? I know that I can do:
symbolic-link(but I don't understand how to undo this or clean it up, even after researching)
alias xxx="/path/to/script&...
0
votes
1
answer
772
views
zsh prompt messed up on arrow up
I think i had got an error like this question.
My prompt is
PROMPT=$'\n%F{cyan}================================%f\n[%*] [%F{yellow}%?%f]\n[%F{cyan}%n@%m%f]\n[%F{green}%~%f]'
For example, i ran:
======...
0
votes
2
answers
334
views
Shell generate command arguments based on a list of strings
I recently came across the following docker command which is so lengthy,
docker run -it -v $PWD/config:/opt/ibm/datapower/drouter/config -v $PWD/local:/opt/ibm/datapower/drouter/local -v $PWD/certs:/...
2
votes
1
answer
3k
views
zshell says command not found in MacOS
I'm using MacOS Monterey 12.4. When I open zsh I get immediately
/etc/zshrc:7: command not found: locale
/etc/zshrc_Apple_Terminal:104: command not found: mkdir
I understand that my terminal ...
1
vote
1
answer
139
views
How to have Ctrl+[key] modify a full word and Alt+[key] modify a partial word in ZSH?
I'm in the process of switching to ZSH as my primary shell and am missing one small configuration option I had in Bash.
I have bash set up so that if I use Ctrl+Left/Right/Backspace/Delete, it will ...
1
vote
0
answers
227
views
How to prevent zsh from printing function contents when executing 'export -f'?
I'm changing my shell from bash to zsh. But there're some scripts in my environment that will be executed when I login the server.
As an example, if I have a script like this:
#!/bin/bash
function ...
3
votes
2
answers
3k
views
Is it possible to have dropdown autocomplete select options in ZSH or Bash?
Is it possible to have dropdown autocomplete select options in the terminal with ZSH or Bash as shown in the image below? Here the regions(i.e. ap-northeast-1, ap-northeast-1 etc) are predefined
4
votes
1
answer
3k
views
How to always execute a command when a shell script function finishes?
I need to write a zsh function with multiple exit points and execute the same clean-up command at every one of them:
function foo {
if ... ; then
...
run_cleanup
return
...
0
votes
1
answer
229
views
which -a bash shows same path multiple times
When I check for bash installation I get multiple bash shown:
➜ ~ which -a bash
/bin/bash
/opt/homebrew/bin/bash
/bin/bash
Why is the same path shown twice? Is there a way to remove one of the /bin/...
0
votes
1
answer
186
views
Bash/Zsh: Catching all commands that start with a `/`
Is there a way to get this example catchall function to be called whenever any command starts with the / character in an interactive shell (instead of searching in $PATH and executing something else, ...
0
votes
1
answer
1k
views
In new version of MacOS I had to switch to zsh, now I have to add double quotes around parameters otherwise it wont work
I would like to get old bash behavior back is this possible ?
With bash I was writing simple:
youtube-dl https://www...
Now I have to write:
youtube-dl "https://www..."
Also in other ...
3
votes
1
answer
1k
views
How to bindkey alt+delete to kill word forward in zsh?
I want to bindkey alt+delete to kill word forward in zsh. Also, I use ohmyzsh for configuration, and I have found that use "bindkey ^U backward-kill-line" to kill line backward like bash. I ...
1
vote
2
answers
6k
views
Can I output `curl` response while also checking for presence of ERROR string?
I have a command I am running with curl. The curl command always resolves successfully even when the server response includes the string ERROR somewhere.
Can I somehow detect this response with some ...
2
votes
0
answers
154
views
Use expansion globs {a..z..2} in zsh like in bash
Both in zsh and bash you can:
> echo {1..10}
1 2 3 4 5 6 7 8 9 10
> echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z
> echo {1..10..2} #range 1 to 10 in steps of 2 (i.e. ...
5
votes
3
answers
9k
views
"Command not found: complete" message appears every time I open the terminal
I was setting up my development environment on Ubuntu 20.04 following a video on Youtube and after running the command
$ echo -e '\n. $HOME/.asdf/completions/asdf.bash' >> ~/.zshrc
Every time I ...
1
vote
1
answer
742
views
/bin/sh: TexturePacker: command not found (while zsh works) macOS Monterey
I have a small Adobe Animate extension that uses TexturePacker to pack sprites onto sprite sheets. I've successfully added TexturePacker to $PATH (/Applications/TexturePacker.app/Contents/MacOS) so it ...
0
votes
2
answers
794
views
Printing the KeyMap pressed in zsh/bash
Is there a way for zsh/bash to print out the keymap of the next received keystroke ?
I would press a key combination on my keyboard, and it would print, say
keymap :
^A
0
votes
0
answers
14
views
aliases for terminal commands not loading on session start [duplicate]
my ~/.bashrc and ~/.zshrc both files have following aliases
# exa to ls
alias l='exa'
alias la='exa -a'
alias ll='exa -lah'
alias ls='exa --grid --color=auto --icons'
# bat alias to cat
alias cat='...
2
votes
1
answer
867
views
Bash or zsh conditional patterns and variable expansions
Suppose I want to generate a filename based on some given variables.
track=01
title="Some title"
album="Some album"
echo ${track}. ${title} (${album})
-> 01. Some title (Some ...
2
votes
1
answer
1k
views
Having your shell commands run after consecutive ssh
I have a function in my zsh source file ~/.zshrc:
function cr() {
ssh -p 5022 [email protected]
ssh servername2
screen -ls
}
However, everything after the first ssh seems to be ...
4
votes
0
answers
1k
views
compgen on zsh returns a different result than on bash
I am trying to make bash completions work properly in zsh.
I am aware of the need to load these in ~/.zshrc:
autoload -Uz +X compinit && compinit
autoload -Uz +X bashcompinit && ...
1
vote
1
answer
3k
views
Pressing Tab Key in Terminal Enters a Space Instead of Triggering Autocomplete
First time asking on this site, please let me know if I can improve the question :)
I'm helping a student configure her mac development environment.
We've got zsh setup, which I believe should come ...
0
votes
1
answer
400
views
How to write a bash function that calls a command with the same name?
I want to write a wrapper around a command that checks a condition before executing the underlying command. I can't figure out how to execute the underlying command without invoking the current ...
20
votes
2
answers
9k
views
zsh: keep all command outputs on terminal screen
I'd like to know how can I get zsh to behave like bash regarding this:
I want command outputs to always show up right below these commands in terminal.
For example, when I run the following command ...
0
votes
0
answers
405
views
How can I redirect the output of a command that only writes to a file, not stdio?
There’s a command I want to run that writes to a specified file. Is it possible to redirect the output of this command to the stdin of another command?
The command looks like this:
foo -o filename
I’...