People who code: we want your input. Take the Survey

Questions tagged [zsh]

Zsh is a shell with many advanced command-line and scripting features.

Filter by
Sorted by
Tagged with
1
vote
0answers
10 views

Add chapter metadata to audiobook using ffmpeg

I have m4a, m4b, and mp4 versions of an audiobook (the video mp4 version just has the book's cover for the entire duration). I'm trying to add chapter metadata to the audiobook using ffmpeg. I've ...
3
votes
3answers
296 views

Correcting .zshrc to ~/.zshrc

Is there a way to set some kind of an alias so that when I do: cd some/directory vim .zshrc It does vim ~/.zshrc?
1
vote
0answers
22 views

Unexpected behavior when querying the PID of bash or zsh when using the --command/-c flag

I am observing odd behavior when examining the PID of certain shells when executed in a non-interpreted context. In the below examples, I see that the PID is pointing to the shell, as expected. sh-4.3$...
1
vote
0answers
9 views

How to disable “Restored Session” message from appearing every time I run Terminal?

Every time I run terminal on macOS BigSur I see this message [Restored 10 Jun 2021 at 12:18:19] Restored session: Thu Jun 10 12:18:16 WEST 2021 I want the sessions to be restored. I don't want to see ...
1
vote
1answer
29 views

Option Arrow keys for moving cursor by word for file paths in terminal (macOS Catalina) in zsh

I've recently updated my terminal shell to zsh on Mac OS Catalina and have found one difference from before, in which I'd prefer the previous behavior. When working in Terminal, using option arrows ...
0
votes
1answer
33 views

Global Variables across scripts [duplicate]

Why is lets say HOME recognized by all my scripts but my variable DMENU isn't? I export it in my bspwmrc file which is executed at start up.Also had it in my zshrc. Why do this? DMENU="-h 27 -z ...
2
votes
2answers
44 views

Find a resource that is missing OSX

On OSX (big sur -so Zhell)I have a folder that contains .bundle files , each bundle containa several files and folders. in most of the files there is a resource called PNG_.zip and some do not. ...
0
votes
0answers
29 views

create dir with custom function [closed]

I want to write a custom command that generates a certain type of dir structure in dependence of the inputs. I am new to linux (i installed Ubuntu 20.04 on 1.6.2021) so please be patiently with me :) ...
0
votes
1answer
31 views

Can I pass a subsequent script execution to an established ssh connection shell

I want to execute a script portion after a successful ssh connection has been established. I'd like to make it easier for me to tail a log file with a script I am trying to write. Here is the script ...
0
votes
1answer
46 views

why is shell (new terminal, new tmux panes/windows) slow to load?

When I open a new terminal it takes a couple seconds for the shell to load, when I open a new pane or window in tmux it might even take a second longer. The delay is about 3 seconds. I'm using zsh ...
1
vote
1answer
72 views

Execute program in current shell within shell script

I made a little shell script, that parses the .ssh config and allows me to pick an entry with fzf, and then connects to that host: #!/bin/bash set -o nounset -o errexit -o pipefail list_remote_hosts(...
4
votes
2answers
50 views

How to launch a command at the startup of only the very first shell of an X session?

I am running Gnome on Pop-OS! 20.04. I am using terminator and zsh shell. I want to launch fortune only the first time I use zsh shell in a X session. I have tried those kind of things in .zshrc: ### ...
2
votes
2answers
46 views

Recover overwritten .zshrc with still-running zsh

I accidentally overwrote my .zshrc file after a misexecuted command, which contains several hundred lines of configs. However, I still have 5 terminals that had zsh open before this incident, and as a ...
-2
votes
0answers
38 views

OpenSSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

I am trying to connect to a ip port using wget: wget https://VCB-ETT-P67:9001/api/DB/dpc Showing error as It is getting connected but showing ssl connection issue Resolving vcb-ett-p67 (vcb-ett-p67).....
1
vote
1answer
22 views

How do I add a command to zsh history?

I'd like to use a zsh script to append a command to the command history so that it appears when I hit the up arrow. I've been appending a line to ${HISTFILE}, and it shows up there as the last line, ...
6
votes
3answers
358 views

Checking if a subdirectory exists using glob in script

I'm trying to check if a directory bin is inside a directory which can sometimes change. In this particular case, the version number of ruby can change (e.g. $HOME/.gem/ruby/2.6.0/bin). Here's what I ...
0
votes
2answers
34 views

Modify array parameter from inside subshell

Is it possible to shift or assign a value to an array parameter from inside a subshell? Example code: arr=(a b c) (shift arr) echo $arr # prints: a b c # should print: b c
3
votes
2answers
93 views

Where are zsh's prompt presets located?

I'd like to create my own prompt but starting from one of the presets that can be obtained from prompt -l. I'd like to know where they're defined so I can duplicate one and pimp it. Also, it'd be nice ...
0
votes
0answers
21 views

zsh: how to change the keybinding for reverse search

I have already a program in archlinux called hstr which searches for history using ctrl+r now i want to use the zsh's history search which uses ctrl+r. Since hstr is already bound to that key, how can ...
2
votes
1answer
27 views

Load specific ZSH_THEME base on specific directory contain specific string

I'm using ohmyzsh. I'm trying to load a diff themes base on the current directory path (pwd) Logics If pwd in or contain sustring /Sites/work/ load af-magic, else load robbyrussell. .zshrc I've tried ...
1
vote
2answers
68 views

/root/.bashrc:157: = not found

#Get client IP base on current logged in user if [ $USER == 'root' ] then ip="$(last | awk 'NR==1 {print $3}')" else ip="$(echo $SSH_CONNECTION | cut -d " " -f 1)"...
0
votes
1answer
29 views

How do I use FZF's keybinding in ZSH's vi mode?

After applying the command: set -o vi in ZSH, I can't get FZF keybinding works as before, ex ^CR for reverse history search.. How can I make this works again?
7
votes
2answers
565 views

How to make Bash/Zsh prompt show only the current directory and its parent?

How can I create a bash and a zsh prompt that shows only the current directory and its parent directory? For example, if I'm at the dir ~/pictures/photos/2021, it should show: [photos/2021]$ echo hi ...
4
votes
2answers
76 views

Zsh use an array in a find command

I would like to rsync over a few files, specified with an array, and delete any other file in a directory. The only approach I can think of is to remove other files using find, and rsync over the ...
-1
votes
1answer
26 views

How to have all contents of a directory run as if they were in your CWD?

Say I have a few directories: /Users/user1/ApplicationThing/ /Users/user1/Documents/ /Users/user1/other/directory/it/doesnt/matter/ Say there was a file main.sh in .../ApplicationThing/, which also ...
-2
votes
1answer
34 views

Equivalent of bash -x for zsh

Is there a way of having the command I just entered echoed onto the screen after entering? Ex: $ echo hello + echo hello hello I know this can be done with bash -x but I could not find the equivalent ...
1
vote
1answer
27 views

How to have everything following a ZSH alias be placed in the middle of its definition?

I have this file: /Users/MYUSERNAME/asciidots/asciidots/__main__.py I want to alias this so that it runs as if it was in my current directory. I was thinking something like this: alias asciidots=&...
0
votes
2answers
62 views

Why my zsh script doesn't echo anything? [duplicate]

script: #!/bin/zsh IFS=$'\n' arr=($(alias | grep 'git' | grep "^[g|\'g]" | sed 's/=.*//' | sed "s/'//")) echo $arr These two lines work in the normal command line: ~/test ·······...
2
votes
2answers
35 views

Create new set of aliases based on current set of aliases (eg. gst -> dst)?

I'm using git aliases from zsh plugins: https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git So it has git aliases like: gst # git status ga # git add gc "commit" # git commit -v "...
0
votes
1answer
33 views

zsh write to a file whose path is stored in a variable

I am trying to append text to a file, where the file name is stored in a variable: x="/path/to/file.txt" echo "some text here" >> "${=x}" But it does not work -- ...
3
votes
1answer
43 views

zsh find -execdir rename “no such file or directory”

I'm trying to write a zsh script on MacOS Big Sur that will recursively rename some files and directories that have special characters I don't want. Been at it for days and every time I think I have ...
1
vote
1answer
56 views

Unable to exclude directory /System on Mac while using find command to scan / directory

I was trying to scan entire Mac for finding files greater than 1GB. I couldn't stop the find command from scanning directories /System and /System/Volumes. find -x / -type f -size +1G I tried prune, !...
4
votes
1answer
318 views

Command not found in zsh, but found in bash

I'm using zsh on ubuntu and I created a symlink for bat as so: ln -s /usr/bin/batcat /home/user_name/.local/bin/bat hitting ls -l from ~/.local/bin shows: lrwxrwxrwx 1 tux tux 15 May 19 13:47 ...
0
votes
1answer
23 views

How do i get this fancy “path bar with git icons” as shown in this picture of zsh

How do i get this fancy "path bar with git icons" as shown in this picture of zsh? What is it called?
0
votes
1answer
25 views

Is there a zsh command to output shell function code, like `type` in bash [duplicate]

In bash, when I'd like to have a glimpse at what an already defined shell function does, I can: $ type myFunctionName For a variable myFunctionName, it provides me with the type of the variable (a ...
0
votes
2answers
108 views

Linux shell command pasting issue

I frequently need to run a script and provide it several lines of STDIN. When doing this, I'll typically prepare the invocations, and then copy & paste them from one terminal window to another. ...
2
votes
1answer
149 views

Why am I seeing % as the line end when running cat file cmd [duplicate]

This really confused me, when I do a cat cmd, I always see something like % at the end of a file, but if I open the file on editor or sublime, it is gone. So how to make sure my file is in a correct ...
0
votes
1answer
70 views

What would be the Zsh equivalent to : ${VAR:=value}

In the traditional Bourne Shell (sh), if one wants to make sure that, at some point in the script, a variable has been set and at least it has some specific default value, one can use this construct: :...
6
votes
3answers
142 views

Is there any reason to avoid sourcing the shell's configuration file?

I recently read an answer here that included the following advice: However, as a rule, ⚠️you should not source ~/.zshrc. Depending on what's in your dotfiles, this can lead to all sorts of problems. ...
2
votes
2answers
92 views

Why do I have to use this command twice to execute it?

I made an alias alias goto="cd $@ && source ~/.zshrc" and it works, but only if I execute it twice. Even after I execute it twice in one shell, and if I want to move to another dir, ...
1
vote
1answer
39 views

Convert bash prompt in Terminal to zsh

I had recently updated Terminal to use zsh, after doing so the prompt on new terminal windows now displays: \[\033[1;92m\]\h:\[\033[0m\] \[\033[0;34m\][\W]\[\033[0m\] \[\033[0;31m\]\u$\[\033[0m\] ...
4
votes
2answers
1k views

How to edit a JSON file using shell?

I am building a shell script that uses a JSON file. { "property1": true, "list": [ { "id": 1, "name": "APP1" }, { &...
0
votes
1answer
33 views

Using the at and batch utilities with zsh on MacOS

I am trying to schedule a one time job with the at utility. I am trying: at 13:00, then hitting enter, then <name_of_shell_script>, then ctrl+d. The top line of my script is: #!/bin/zsh but it ...
32
votes
3answers
4k views

I just deleted everything in my home directory. How? And why are some files still there?

Never thought this would happen to me, but there you go. ¯\_(ツ)_/¯ I ran a build script from a repository inside the wrong directory without looking at the source first. Here's the script Scripts/...
1
vote
1answer
46 views

Remove quotes from stdout. Pass string as file path

I was trying to create a bookmark file for my configs, and search for them using fzf. I tried both these methods but with no avail. editconf() { nvim $(cat /home/anupam/scripts/conflist | fzf) } ...
0
votes
0answers
12 views

oh my zsh git email in prompt not refreshing

Problem I have oh my zsh installed on mac OS catalina and using iTerm2 as terminal. I am using robbyrussell.zsh-theme theme and have modified it to print git email in the prompt (More info here). I ...
0
votes
0answers
26 views

ZSH Menu Select Autocomplete: VIM navigation & search functionality. Is it possible?

Is there an option I can set to allow these to work together? H,J,K,L (VIM keybinds): Navigate menu select rows & columns / (Search Toggle) that temporarily disables the VIM bindings zstyle '...
0
votes
0answers
14 views

Generate zsh aliases from zsh script [duplicate]

I wrote a simple script for generating aliases in zsh shell. Here it is: for subject in $(find $path -maxdepth 2 -type d -print) do dir=$(printf -- "$subject\n" | sed 's|.*/||') alias &...
0
votes
1answer
26 views

ZSH Environment variables

What is the difference between these two lines: export XDG_CONFIG_HOME="$HOME/.config" export XINITRC="${XDG_CONFIG_HOME:-$HOME/.config}/x11/xinitrc" And these two lines: export ...
1
vote
1answer
40 views

How to check if command had any output (zsh)

I want to print a new line after a command if it had any output (I hope that this will make it more readable once my terminal starts scrolling). I found this: precmd() { precmd() { print &...

1
2 3 4 5
47