All Questions
54 questions
0
votes
1
answer
88
views
Why does find ....-execdir rename miss files? zsh
I'm using zsh on MX Linux 23.2.
For years I have tried to figure out why a command like
find . -depth -type f -execdir rename 's/_720p//' {} \;
skips over files.
I know my file manager can't be ...
0
votes
1
answer
39
views
Thunar custom actions - how to import selections into zsh script
Xubuntu 22.04 Thunar 4.16
I am working on a script that works similarly to detox but does not require root privileges as it will only be allowed to operate on files or folders in the user's home ...
0
votes
1
answer
80
views
Zsh: What is the idiomatic way of terminating lines in a script? (semicolon, new-line) [closed]
I'm fairly comfortable with putting semicolons, newlines and ampersands where they're needed. But what is the "correct" way? Is it just a matter of style/personal preference, or is one in ...
3
votes
2
answers
138
views
How and why does using redirection or writing files within an if statement affect exit code?
In zsh
echo 'a string' > test.txt
echo $?
0
and
[[ $(echo 'a string') ]]
echo $?
0
whereas
[[ $(echo 'a string' > test.txt) ]]
echo $?
1
another example
curl -so 'curl-8.2.1.tar.gz' https://...
4
votes
2
answers
220
views
How to make the (N) patterns of the zsh eatable by bash?
I am trying to develop a script which runs (and, ideally, does the same :-) ) in zsh and Bash. Problem is, that at a point, the zsh-specific part contains a pattern ending with (N). So: this_pattern*(...
0
votes
1
answer
243
views
Zsh script to recursively unrar into a folder with the same name [duplicate]
Is it possible to use a zsh script to unrar all directories within another directory?
As follows:
dir
|_dir1.rar
|_dir2.rar
|_dir3.rar
I would like the command not to include the cd. I will cd into ...
0
votes
1
answer
907
views
Shell script: How to prepend env variable with prefix only if environment variable is defined?
Given command that requires flag --flag. We want to insert this flag only when the value of the flag is provided as environment variable VALUE.
I tried the following:
echo "command ${X+--flag ${...
0
votes
1
answer
48
views
Script input data run commands based off it
Not sure where to begin I only know basic text processing.
I am trying to create a script that will search for zfs snapshots based off a VM name (given as a command parametet) and then select the ...
2
votes
1
answer
840
views
Does bash (or zsh) "officially" mandate the use of tabs for indentation in scripts?
I recently came across the following statement (source; emphasis added):
For shell scripts, using tabs is not a matter of preference or style; it's how the language is defined.
I am trying to make ...
1
vote
1
answer
3k
views
Displaying icons for directories in zsh prompt
This is, roughly, my left prompt for zsh:
# Libraries
autoload -Uz colors && colors
# User color
if [ "$(whoami)" = "root" ]; then
COLOR="red"
elif [ "$(...
0
votes
3
answers
242
views
Writing a zsh script that goes in order
I am using Big Sur and I am trying to write a script that will make a package run (the package is XSPEC, a spectral fitting package from NASA), and then run commands run in that package. I start with ...
0
votes
1
answer
53
views
In a bash/zsh function how do I do something, then depending on the output, do A or B?
This function looks through each local git repository in folder ~/src, and does git pull on it. More and more I keep getting an error
Please commit your changes or stash them before you merge.
...
1
vote
1
answer
312
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(...
0
votes
0
answers
19
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
1
answer
1k
views
zsh script cannot find commmands [duplicate]
I'm attempting to run this zsh script:
#!/bin/zsh
paths=(
"/docs/"
)
for path in $paths; do
dirsearch.py -u "http://10.129.140.251:8080$path" \
-r --csv-report=&...