New answers tagged

-1

You can create a script.sh that contains all your commands, each ended by &. A bash script will execute one by one the commands listed. #! /bin/bash command1 &; command2 &; However if your commands are not bash commands but scripts or other programs, bash will play the role of a launcher. Therefore it will concider that his work is done ...


3

(command1; command2)& - should do it, works in bash. This creates a subshell (the two parenthesis) and runs the whole subshell in the background.


0

What about using https://github.com/zsh-users/zsh-autosuggestions? The thing is, for each command you type this plugin will show you some suggestions that could be accepted or not. Try it out and give us some feedback.


1

Use emacs, start an inferior shell and issue your command. The output will be available in the shell buffer and can be selected using the usual commands. Alternatively, select file in $(find <whatever>); do vi $file; break; done The emacs approach is more practical if you already know the editor. Emacs can run arbitrary "inferior processes", ie. ...


1

Turns out that removing all ~/.zcompdump files solved it: rm -r ~/.zcompdump*


0

In answer to the question is my zsh completion script _cheat considered a "completer" in the context string? The answer seems to be no If you use ESC2, CTRL+x,h to dump zsh's completion context % cheat b tags in context ...


1

With recent Linux, printf foo > /proc/$$/comm will change the executable name (the ps -p thing) provided "noclobber" isn't set (and the wind is in the right direction). In zsh, printf foo >! /proc/$$/comm works regardless of clobbering state.


0

Much thanks to @st├ęphane-chazelas who pointed out all the problems with my previous attempts, this now seems to work to serialise an array to stdout or into a variable. This technique does not shell-parse the input (unlike declare -a/declare -p) and so is safe against malicious insertion of metacharacters in the serialised text. Note: newlines are not ...


2

Try pressing Control+[ immediately followed by h. Terminals do not send key presses directly to the shell (as in Control was pressed/released). Instead the terminal sends character sequences depending on keys pressed. The keys in a sequence are to be pressed - well - in sequence, not all at once. The big exception to this are the Control-keys and the ...


1

^[ actually means Escape character. Check here: https://en.wikipedia.org/wiki/ASCII In your case it seems your ALT key works as a synonym for Escape key: https://en.wikipedia.org/wiki/Alt_key


4

? is special (being used by both glob and history expansion, see zshexpn(1)), and thus requires escaping, but otherwise can be used as an alias, though probably should not be, given that it is special. % alias \?='echo hi' % ? hi


1

It seems that prezto is loading the module from /usr/lib/prezto/modules/completion. With everything enabled, I deleted the contents of /usr/lib/prezto/modules/completion/init.zsh, which gave me the second quickest load time again. I then started systematically deleting lines in this file, and could isolate a single line causing the slowdowns. unsetopt ...


4

That is because you are trying to use the GNU find, which is default in Linux, but Mac OS X comes with BSD find which has many differences. To install GNU find you will need Homebrew, pretty easy to install, just follow http://brew.sh/ After that you can install findutils: brew install findutils More info and other tools to mimic a Linux environment on ...


4

% PS1='%% ' exec zsh -f % autoload -U compinit && compinit % setopt GLOB_COMPLETE % touch aa ab ac ad % vim a* Will cycle through the options; and then for a menu (on, like, everything) % zstyle ':completion*:default' menu 'select=0' % vim a* For more information see zshoptions(1) and the "From Bash to Z Shell" book for slightly readable docs on ...


0

The correct command to disable the double verification seems to be setopt rm_star_silent. To enable the double verification do setopt no_rm_star_silent. For more detailed information look at the man page for zshoptions man zshoptionsor http://linux.die.net/man/1/zshoptions


0

Include this in your shell: git(){ case "$1" in clone) git-clone "${@:2}";; *) command git "$@";; esac } git-clone(){ local tgt tgt=$(command git clone "$@" 2> >(tee /dev/stderr |head -n1 | cut -d \' -f2)) || return $? cd "$tgt" } This works by surreptisiously gleaning the cloning target from git's standard error and cd'ing into ...


0

You could do something like: clone_check() { (($? != 0)) && return local cmd=$history[$((HISTCMD-1))] cmd=("${(@Q)${(z)cmd}}") if [[ $cmd = "git clone "* ]]; then local dir if (($#cmd == 3)); then dir=${cmd[3]:t} dir=${dir%.git} dir=${dir#*:} elif (($#cmd > 3)); then dir=$cmd[-1] else return ...


0

A simple solution for any POSIX shell is to specify the directory to clone to explicitly (any filesystem path) and reuse it: git clone <repository> <directory> && cd "$_" and cd - when you're done.


2

How about using read? $ cat /dev/null | read pointless || echo no output no output $ echo something | read pointless || echo no output $ printf "\n" | read pointless || echo no output $ printf " \n" | read pointless || echo no output $ false | read pointless || echo no output no output According to the Open Group definition: EXIT STATUS The ...


0

I had the exact same issue and wrote a ZSH plugin which solves it: https://github.com/tymm/zsh-directory-history You don't have to manually switch between global and directory history when using my plugin. Ideally, every other matching history command will appear after those, optionally specifying a max number of priority elements. This also works ...


0

I figured out what the problem was. Based on @L. Levrel's comment, I added an echo statement to the .zshrc, since he said that ssh login shells are both interactive and login. And sure enough, the .zshrc gets sourced AFTER the .zprofile, and the path is being overwritten in .zshrc. Moving the export command for the Java variable to ~/.zshrc solved the ...


0

zsh fc -l -5 # 5 most recent fc -l 1 5 # 5 oldest fc -l -10 -5 # 10th newest to 5 newest


5

The standard way to define directory abbreviations for the prompt is to use named directories. Named directories are used when expanding the %~ prompt escape sequence, generalizing ~ to abbreviate your home directory and ~bob to abbreviate Bob's home directory. mu3 [~]: cd /Users/mu3/Development/Web/test mu3 [~/Development/Web/test]: hash -d test=$PWD mu3 ...


2

You can (as in bash) use a function in your prompt. Here is an example: setopt PROMPT_SUBST print_dir(){ case $PWD in (*/Development*) echo DEV/${PWD:t} ;; (*) echo $PWD ;; esac } export PROMPT=$'[$(print_dir)]: ' The zshall manual page documents PROMPT_SUBST: If the PROMPT_SUBST option is set, the prompt string is first ...


1

You can setup a pager to capture output and then quit if it fits on one screen. When it doesn't fit, you can use the pager to scroll and search. export PAGER=less export LESS=-FSXRi # -F and -X are relevant here, but that's what I use # also, less quickly toggles most by typing '-' and the option I imagine zsh has a way to automatically modify commands ...


1

The simple typeset -U dirstack fails, as dirstack is doubtless too special for the usual unique limitation to apply (this typeset is however handy for things like the path array). On closer inspection the Arch Wiki code suffers from incomplete uniqueness, in that only dirstack only when being written out is made unique, and not with PWD, nor when reading the ...


1

You can reverse the order of the files (sort --reverse) so the latest files will always be the first in a block of files with the same prefix. Then you can keep track of the current block (with $current_prefix) and keep the first file in each block (continue) and rm all the other files in the block: current_prefix= find . -name '???_*.txt' | sort --reverse ...


0

I know this is really late, but perhaps you can work around your issue of making the underscore more accessible. xmodmap -e "keycode 20 = underscore minus" This will switch underscore with hyphen (minus). So now, you hold shift for hyphen, but an underscore is typed without shift. Your keycode may be different, however, I think it depends on your ...


-2

cd /my/directory/path for file in * do grep -v '^$' < "${file}" | tail -1 | grep "hello world" > /dev/null; result=${?} if [ "${result}" -ne 0 ] then echo "${file}" fi done The grep -v '^$' < "${file}" part eliminates empty lines that might be added to the end. If this is not desired, you can omit that part and start that line as tail -1 ...


4

Try: for f in *; do if [ -f "$f" ] && [ "$(tail -n1 -- "$f")" != "hello world" ]; then printf '%s\n' "$f" fi done


2

Give this tested version a try: #!/usr/bin/awk -f BEGIN { last=FILENAME; } { if (last != FILENAME) { if (line !~ /^hello world$/ && line != "hello world") { print last; } last=FILENAME; } line=$0; } END { if (line !~ /^hello world$/ && line != "hello world") { print FILENAME; } } The test: $ chmod +x ...



Top 50 recent answers are included