All Questions
Tagged with zsh shell-script
30
questions
0
votes
1
answer
1k
views
How to determine if a screen is running jobs without attaching to it?
I wrote a zsh script that launches many screen sessions and runs a different command in each of them. When the script is executed there are 72 screens in total, so checking if a job is finished or not ...
2
votes
4
answers
1k
views
How to merge ls commands colors with the output of find or du?
I have a simple alias to list the size of files&folders in cwd.
( including dotfiles in this case , ignoring zero sizes )
du -sh .[!.]* * | sort -hr | grep -v '^0'
which can be achieved aswell ...
1
vote
2
answers
635
views
tar backup zsh script
Trying to set up a cronjob ran tar script to backup site (without .git and setup folder) every night and upload time stamped archive to Dropbox.
It gives me a hard time as archive is created along ...
4
votes
1
answer
3k
views
Script-specific autocomplete in shell
I create a lot of little scripts to help me in my every day life.
I would like to provide auto-complete for them, specially that I intend to share them with people.
Now, I know I can create auto-...
23
votes
2
answers
9k
views
Writing shell scripts that will run on any shell (using multiple shebang lines?)
I've just started getting deeper into shell scripting, and I've always just thrown my script in a file, marked it chmod +x and then done /path/to/script.sh and let whatever interpreter is the default ...
5
votes
2
answers
6k
views
Efficient way to use all cores in bash or zsh script
If I want to process large number of files with command "do_something" which only can use one core, what's the best way to use all available cores assuming each file can be processed independently?
...
0
votes
1
answer
442
views
zsh expansion modifiers in scripts
I've just found out that ZSH's modifiers only work in interactive scripts, so the following will work correctly on the command line but not from a script (the script ignores the modifier and echoes ...
2
votes
1
answer
7k
views
Deleting a file if it exists or not
Here is a part of my zshrc file.
## Most Frequently used settings
# ls
alias ls='rm .DS_Store; echo --------------${PWD##*/}--------------; ls -1FGu'
alias l='ls -A'
I want to delete .DS_Store, ...
2
votes
1
answer
8k
views
Creating a link for all files in a directory to home
I am trying to write a small zsh (bash compatible) script to take each file in ~/.oh-my-zsh/links directory and creates a hard link for it in ~. I am not sure how to do this. Would this be correct?
...
0
votes
3
answers
1k
views
High performance perforce sync
I am trying to do p4 sync folder/...
It's not very fast and it's using only 2% of the CPU. I am not happy with the performance.
I am trying to write a function in bash, given a parameter n, it forms ...
0
votes
1
answer
153
views
Diff between files in different directories
I have the follow directory structure
./goodboys/a.txt
./goodboys/b.txt
./badboys/a.txt.boy
./badboys/b.txt.boy
I am using zsh. I want to diff all *.txt in goodboys with *.txt.boy in badboys.
I am ...
5
votes
2
answers
2k
views
How to search *upwards* for file? (reverse find)
I'd like to search "upwards" for a file in shell script, e.g. check $PWD, then $PWD/.., then $PWD/../.., etc. until hitting the root. Before I go and roll my own, is there some builtin bash/zsh/find ...
1
vote
1
answer
1k
views
Under zsh, looking to use `tr` to search and replace a single character with multiple characters
I want to replace "Blah: whatever" or "Blah/Whatever" with "Blah--Whatever"
I have this:
NEW=`echo ${OLD} | tr '[:/]' '--'`
echo ${NEW}
I suppose it's taking the 2 dash characters to mean 1 letter ...
3
votes
4
answers
3k
views
Loop: Start program and kill after time out
for debugging reasons I want to spot one of those bugs showing up just occasionally. Therefore I want to code a while loop in the shell
starting the program (if it will segfault => that's what I want)...
2
votes
2
answers
2k
views
On OS X, how do I start Cocoa emacs *and* bring it to front?
I wrote a little zsh function to allow me to run emacs from the command-line:
function emacs() {
/Applications/Emacs.app/Contents/MacOS/Emacs $@ &
}
This works perfectly, but it seems to ...