Tag Info

Hot answers tagged

7

You can not do it. Because aliases were expanded only after history expansion and entire line was read in one go, so when foo was executed, the alias expansion process was gone, it's too late for the shell to recognize new alias. The best way you can do is defining alias in .zshrc or using function like jimmij's answer or using eval: alias foo=ls; eval ...


7

This is very well known problem which is even described in zsh manual under chapter ALIASING (see man zshmisc). The recomended way of dealing with it is to use function instead of alias: foo() { ls; } ; foo or even better in case of ls: foo() { ls -- "${@:-.}"; } ; foo ps. semicolon at the end of the function definition (list) and spaces are not ...


7

When you press Ctrl+Z in a terminal, this causes the foreground process group to receive the signal SIGTSTP (assuming the terminal is in cooked mode and the default key bindings are in place). If the process hasn't set a signal handler for SIGTSTP, this causes the process to be suspended (and even if the process has set a signal handler, it usually only does ...


6

Having a global keybind to disown the foreground process is impossible: Keystrokes are received by the foreground process, not by the shell. You need to first suspend it with Ctrl+z if you want to disown it. However, turns out there's a zsh option to speed up disowning then continuing: With setopt AUTO_CONTINUE, disown will automatically also send SIGCONT. ...


3

zsh -o SOURCE_TRACE and some more words to get to at least 30 characters.


3

For a Standard Shell (bash) (POSIX.1) Start it with &, make it read from something other then the default stdin (==/dev/tty == /dev/stdin == /dev/fd/0) + make it write to something other than the default stdout (==/dev/tty == /dev/stdin == /dev/fd/1) (same for stderr) and make sure the job isn't or doesn't get suspended(=stopped). If it must get stopped ...


2

The equivalent of the * regexp operator in zsh -o extendedglob is # (## for +). And you can also use ksh-style globbing with the kshglob option. So either: setopt extendedglob # best in ~/.zshrc ls -d filename.mainsuff_[[:alnum:]]# Or: setopt kshglob ls -d filename.mainsuff_*([[:alnum:]])(-) (The (-) part is to prevent ([[:alnum:]]) from being taken as ...


2

So I am still trying to flesh this out, but I think I have an idea that will work. As you have noticed what you are trying to do is if not impossible exceedingly difficult to do in the all shells (each variant you add to the polyglot increases the complexity at a greater than linear rate). you could probably do it if you split into borne (sh, ash, dash, ...


1

You can always declare a function for that: map() { local arrayname="$1" cmd="$2" i shift 2 eval "$arrayname=()" for i do eval "$arrayname+=(\"\$($cmd)\")" done } And use as: $ a=(a '' bcd) $ map b 'wc -c <<< "$i"' "$a[@]" $ echo $b 2 1 4


1

try somethings like this shell_bin=$(ps h -p $$ -o args='' | cut -f1 -d' ') echo $shell_bin


1

You may find useful (though it doesn't use disown, nohup or &) trying screen or tmux. Both tools allow you to run multiple terminals and detach from them without stopping what its happening in each one. I find tmux more convenient. Using tmux You can name sessions, tmux new-session -s ${SESSION_NAME} start one without attaching to it, tmux ...


1

I believe you cannot always get the current shell's name, and I think you should be aware of the limitations of what is possible. On Linux distributions, most users would have bash as their login & interactive shell (since bash is the default shell on most distros). Some users would set their shell to zsh, csh (and variants) or to fish. (As other ...


1

Please, on behalf of future maintenance programmers and sysadmins - DON'T use a regex to parse XML. XML is a structured data type, and it is NOT well suited for regex parsing - you can 'fake it' by pretending it's plain text, but there's a bunch of semantically identical things in XML that don't parse the same. You can embed linefeeds, and have unary tags ...


1

** doesn't follow symlinks since bash-4.3. See CHANGES between bash-4.3-release and bash-4.3-rc2: globstar (**) no longer traverses symbolic links that resolve to directories. This eliminates some duplicate entries.


1

You can batch process your files with mogrify and convert from one format to another using the -path option (as of imagemagick v6.2.0) to specify a different directory in which to output the processed images: mogrify -path /path/to/dest_filename -format ext2 /path/to/source_filename/*.ext1 so e.g. mogrify -path /home/myjpgs -format jpg ...



Only top voted, non community-wiki answers of a minimum length are eligible