1
vote
2answers
199 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 ...
1
vote
1answer
279 views

zsh - variable assignment isn't working

I have this line in a function I'm adapting from a bash function into zsh function: local info=( $(command df -P $fs | awk 'END{ print $2,$3,$5 }') ) Whenever I call it in the func I get this: ...
1
vote
2answers
264 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 ...
3
votes
1answer
410 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 ...
6
votes
2answers
1k 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 ...
4
votes
2answers
361 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
1answer
67 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 ...
0
votes
1answer
101 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
1answer
2k 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
2answers
254 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
1answer
61 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 ...
3
votes
2answers
403 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
1answer
276 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 ...
2
votes
4answers
1k 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 ...
1
vote
2answers
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 ...