All Questions
Tagged with command-line zsh
171
questions
1
vote
2
answers
96
views
how to pipe output from a command in its own shell?
I want to put all output as it's happening into say so it can read my LLMs response
I found that tee will output the lot once you exit but I want it to say each response when they are given.
I think ...
0
votes
0
answers
14
views
Run a command, immediately return to the shell prompt, do not return a message when the command is finished [duplicate]
brew install gh > /dev/null 2>&1 &
This returns to the shell immediately, but prints [1] + done brew install gh > /dev/null 2>&1 when the command finishes.
brew install ...
0
votes
0
answers
120
views
MacOs equivalent of adding a user to the linux dialout group on for permissions setup for UART communication
I'm working on a project where I'm interfacing with some hardware and want to monitor the data from some sensors using a specific tool. The tool doesn't have official support for MacOS but I've ...
-1
votes
1
answer
775
views
Can't use terminal, I keep getting "zsh: command not found: npm" even after an OS re-install
I don't remember what I had done, but every time I attempt to run a command (npm install -g gulp) in terminal, it returns a zsh: command not found: npm. This is a command I previously had no issue ...
0
votes
1
answer
134
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 ...
0
votes
1
answer
170
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
236
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 ...
2
votes
1
answer
109
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
...
1
vote
0
answers
95
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
158
views
zsh-syntax-highlighting writes parameter expansion in black
I have installed zsh-syntax-highlighting. This works well, except of one oddity: When I type a parameter expansion as a command argument, i.e.
foo $PWD
as soon as I type the $P, the parameter ...
1
vote
1
answer
93
views
zsh completion ( compctl ) does not trig for command names containing dashes
I've used zsh compctl since forever (late 90s or early 00s) but strangly never run into this before.
I realized today when I intended to make some compctl config for update-alternatives that my ...
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 ...
1
vote
1
answer
814
views
How do I print a newline after there user enters a password with zshbuiltin read command
I want to read a user's password securely within the execution of a curl command. A made a basic proof of concept which mostly works, but the output of the echo command is coming on the same line as ...
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
0
answers
333
views
Alias not exported from .zprofile to folder location that exists
In my .zprofile, I have a bunch of aliases that follow the same pattern:
export remotedir="$HOME/remote"
export localdir="$HOME/local"
etc.
They all work, except for one, which ...
0
votes
1
answer
22
views
How to make an output file specific to each variable in while read line loop? Nikto ZSH
In Zsh, I want to run a Nikto scan on a list of URLs and have the output be:
($line)-nikto-results.html
I have so far :
while IFS= read -r line;
do nikto -h $line -o $line-nikto-results.html -F html;
...
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:
======...
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
2k
views
Variable with special character in a string in zsh
I'm trying to create a variable $creds using the command line for storing credentials that I use over and over in some terminal sessions. The value in the string looks like -u myusername -p mypass!...
1
vote
1
answer
249
views
zsh alias for running the most recent matching history item
I'd like to create an alias in zsh that runs my last terminal command beginning with node. I can run that command with !?node, but I can't create an alias with alias N='!?node'. How can I make this ...
0
votes
0
answers
87
views
How can I change terminals command line color?
I found that this terminal is so beautiful. But I don't know how to configure it.
In this video, you can see that the command and argument are in different colors like this
.
I'm developing on macOS ...
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, ...
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 ...
1
vote
1
answer
586
views
ZSH Colorize the PWD output in aliases
NOTE: Yes, This is on Mac OS 11.6.2 Big Sur.
Right now I have zsh aliases in the .zshrc file to make terminal navigation easier. I thought I'd try to colorize the PWD output, but what happens is that ...
2
votes
0
answers
336
views
zsh change RPROMPT time on enter
I have found resources on configuring zsh's right prompt (RPROMPT) to be the date and time and this works great.
However the time the prompt renders (after the last command) and the time that I press ...
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 ...
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’...
1
vote
2
answers
651
views
bash && zsh: referencing / repeating a previous command line *argument* while still crafting the same line
Let's say I am entering some complex command that repeats one of the command line arguments, or some variation of one of the arguments, and let's say I'm dealing with very long and complex command ...
1
vote
1
answer
119
views
Changing default Dropbox at command line to a business account from a personal account on macOS
I've linked to my business Dropbox on my Mac which already had my personal Dropbox installed. I can easily access both my Dropbox (Personal) and Dropbox (Business-name) from the Finder.
At the command ...
1
vote
1
answer
363
views
Shell appending unknown integer to hostname in prompt (zsh) on mac
I recently customized the prompt in my terminal to be more like the one from parrot os, which I really like. I have read over the documentation many times on how to use the markers/variables in the ...
0
votes
1
answer
526
views
R and shell in macOS Catalina
I just got a new M1 mac with macOS Catalina at my workplace, and I'm having trouble when running R from the command line (actually, when running it from a Makefile). I'm relatively new to the shell so ...
5
votes
1
answer
3k
views
zsh bindkey does not change behavior of up and down arrow keys
I want to change the key bindings of the up and down arrow keys. By default I have:
bindkey
...
"^[[A" up-line-or-history
"^[[B" down-line-or-history
...
I have added these lines ...
1
vote
1
answer
2k
views
Global alias in zshrc file
I am using the command line in a MacBookPro terminal, with zsh as the default profile.
I am trying to write a global alias to the zshrc in my home directory file but encounter a strange error.
If I ...
1
vote
1
answer
550
views
-v unary conditional expression isn't working
I want to check if the given variable is set with the -v check. I'm struggling to understand where the error is coming from. Having the following script in a file var-test.sh:
MY_VAR="test"
...
0
votes
1
answer
804
views
Kal Linux command line is messed up
I'm using Kali Linux live booting off a USB flash drive and for some reason my command line looks like this:
I've looked on Google and can't find a way to get a regular straight command line. I tried ...
2
votes
1
answer
305
views
ZSH prompt: path except current dir
Can zsh set the prompt to the whole path except the current dir? I.e. for ~/a/b/c/ to just ~/a/b/?
I'm trying to get this result for ~/a/b/c with left & right prompts:
c/: | ~/a/b/...
0
votes
2
answers
290
views
Shell history of *expanded* commands
Is there some way to get the actual expanded contents of a command-line that I ran recently? By this I mean the literal "argv", not the text before parameter expansion and similar steps.
In ...
0
votes
1
answer
512
views
How do I get single-Enter execution with Oh My Zsh when using event designators? [duplicate]
In plain zsh, when I press Enter, it runs the command I've typed. Hooray! This includes performing any necessary event designator substitutions all in one go, though it prints them out along the way:
~...
2
votes
1
answer
2k
views
ZSH prints the command I ran before showing the output
I'm using OhMyZsh with the PowerLevel9K theme and ZSH always prints the command I ran first (just the command without the arguments) before actually showing the output:
$ ls
ls<dir1> <dir2>...
2
votes
1
answer
639
views
What is the zsh equivalent of bash's "command" command?
I've overwritten my cd command with pushd so I don't have to remember to use pushd and can easily get back to where I've been. Now I want to use the actual cd command.
In bash, I would use command cd ...
0
votes
1
answer
1k
views
ssh remote command with zsh: zsh:1: no matches found
I am writing a script to zip some file on remote server and then transfer it.
I got the error with remote ssh command and wildcard like that
ssh 1.2.3.4 "ls /home/lhc/*.txt"
zsh:1: no ...
3
votes
1
answer
321
views
Insert multiple lines from zsh history
I'm trying to easily insert multiple lines from my history into the current prompt (to implement https://github.com/junegunn/fzf/issues/1806).
Given I have the numbers of the lines, how do I insert a ...
1
vote
1
answer
169
views
comm command output in bash versus zsh
In the process of transitioning from bash to zsh. I am comparing the contents of two folders, and echo the files that are common:
common_files=$(comm -12 <(ls -p "$folder1") <(ls -p &...
3
votes
1
answer
2k
views
Running python script without typing its `.py` extension
I'm using Zsh on MacOS Catalina.
I was reading Automate the Boring Stuff with Python and in it the author runs mapIt.py simply by typing mapit into the terminal.
In order to do this I added a ...
1
vote
1
answer
1k
views
Stuck in zsh command trying to load .bash_profile after switching from bash on MacOS
I've just switched from bash to zsh on MacOS and I wanted to load my current .bash_profile so I did:
Added #!/bin/zsh to my .bash_profile and ran:
% . ~/.bash_profile
And I was stuck because of ...