26
votes
Run two scripts after each other in the background? && and & don't work?
That's one of the known deviations¹ of zsh compared to sh (or csh for that matters).
In sh:
A && B &
is short for:
(A && B) &
That is, it runs a subshell that runs that and-...
8
votes
Run two scripts after each other in the background? && and & don't work?
You have to group the two commands together:
nohup sh -c 'a.sh; b.sh' &
Replace ; with && if you want b.sh to run only if a.sh exits with success
7
votes
Accepted
How to get both the number of bytes and the sha1sum with single pass?
Would be easier to use temp files. In zsh:
(){set -o localoptions -o pipefail; local IFS
{cmd} > >(sha1sum > $1) | wc -c | read bytes || return
read checksum rest_ignored < $1 || ...
3
votes
In terminal, how to delete a word when cursor is within the word?
If you are using a shell which uses readline(3) as bash, you have either to combine two shortcuts:Alt-dAlt-Backspace
Or you define a key which is not already in use, see the output of the command ...
3
votes
Equivalent of PSReadLine for bash
Bash, which is the default shell in Ubuntu and most GNU/Linux distribution, does not come with support for most of these fancy features. Though you can get closer with a couple tweaks to the ...
3
votes
Add a process to an already executing process? Like && or so
Only the parent process (or the child subreaper if any or init if the parent died), can retrieve the exit status of a process.
From the shell where you started the command, you can wait for it, and ...
3
votes
Add a process to an already executing process? Like && or so
If the shell that started the process still knows about it (try jobs), then the shell built in wait can wait for it to finish. Something like this might work:
$ jobs
[1] nohup a.sh
$ wait -f %1 &&...
2
votes
How to get both the number of bytes and the sha1sum with single pass?
I am using a backup bash script which has the following helper "in-between" functions which take a "supposed filename" as an argument (see tar.gz example below):
function pipesum
{
...
2
votes
Disabling the secondary prompt in zsh
There is a zsh plugin that disables secondary prompt: https://github.com/romkatv/zsh-no-ps2. If the currently typed command is well-formed, pressing Enter executes it as usual. Otherwise it inserts a ...
2
votes
Accepted
OSX13; how to mv series of x numbers of file chunks simultaneously to the series of directories
Sounds like just a matter of
autoload -Uz zmv
zmv '(GSM<->_<->)_*' '$1/$f'
1
vote
Function with aliased command works with eval but not shell expansion
Aliases are special. They're handled early in the command line processing, before parsing is fully done, and they work more like straight-up text replacement than calling a separate function.
With ...
1
vote
Function with aliased command works with eval but not shell expansion
You want either:
cmd=(
main_cmd hard_coded_arg_1 hard_coded_arg_2
-a "$opt1"
-b hard_coded_opt
"$2"
)
"${cmd[@]}"
Where we define an array that has these ...
1
vote
identify content inside base64 encoded content and replace the whole line
Assuming you want to:
find base64 encoded data after any occurrence of -encodedcommand (case insensitive) followed by whitespace
decode it into something assumed to be a multiline UTF16-LE encoded ...
1
vote
Accepted
Pass ssh remote command from bash to zsh
On some (most these days) systems, bash is configured at build time so that when run over ssh, bash reads ~/.bashrc (and corresponding system-wide file in /etc) even when run non-interactively like ...
1
vote
In terminal, how to delete a word when cursor is within the word?
zsh's line editor supports all of vim's [cd][ai][wW] (even an extra [cd][ia]a as a bonus) out of the box when in vi mode (entered with bindkey -v like in tcsh or set -o vi like in ksh).
See info zsh '...
1
vote
How can I automatically wrap every command in Zsh/Bash with a custom command before execution?
I will assume you will want to enter and exit out of this arrangement so I made the following.
For zsh, the DEBUG trap handler can skip the execution of a submitted command by setting the ERR_EXIT ...
1
vote
Modify tmux run-shell PATH
The shell tmux uses inside run-shell gets environment variables from the tmux server. Depending on how you started the tmux server and what happened later, the resulting environment may or may not ...
1
vote
Key binding to swap shell foreground/background jobs
This makes issuing CTRL+Z immediately resume the previous job, as long as you have more than 1 job suspended. The only way to exit the while loop is to close programs until at most 1 backgrounded ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
zsh × 2936bash × 560
shell × 516
autocomplete × 313
shell-script × 285
oh-my-zsh × 270
macos × 160
terminal × 153
command-history × 150
command-line × 122
wildcards × 119
prompt × 114
alias × 111
linux × 81
tmux × 73
environment-variables × 72
function × 63
keyboard-shortcuts × 61
path × 53
scripting × 51
ssh × 50
colors × 48
zle × 47
quoting × 44
array × 43