Tag Info

New answers tagged

1

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 ...


0

I had been wanting to integrate Zsh's cut buffer with the X clipboard. I tried the aforementioned http://stchaz.free.fr/mouse.zsh but I found I disliked having all my Zsh operations populate the clipboard. For instance, sometimes I would copy something in a browser, and then go to a shell and edit the command line and then paste. But often editing the ...


1

You have two copies of screen. One of them stores its sessions in /tmp/uscreens and the other stores its sessions in /var/run/screen, so they don't see each other's sessions. Even if you could force them to see each other's sessions there's a chance that the copies of screen are different versions and bad things would happen if the two talked to one ...


2

Works fine here with zsh v. 5.0.8 Brace expansion with single characters was added in Jan 20141 so if you're using a version prior to 5.0.6 then it's not available. 1: see also the discussion here


4

Set your Warning options as an array. "${warnings[@]}" generates 3 individual words warnings=(-Wall -Wextra -Wpedantic) "${compiler}" "${warnings[@]}" "${standard}" -o "${1}" "${1}.cpp" Or, if you find it more legible, you can create the array without -W's, and then add -W's via how you present the array on the command line. warnings=( all extra ...


3

zsh do not read .zshrc in non-interactive shell, but zsh allow you to invoke an interactive shell to run a script: $ zsh -ic 'type f' f is a shell function or you can always source .zshrc manually: $ zsh -c '. ~/.zshrc; type f' f is a shell function


5

This should do the trick: awk -F '[<>]' ' NR!=1 && FNR==1{printf "\n"} FNR==1{sub(".*/", "", FILENAME); sub(".xml$", "", FILENAME); printf FILENAME} /double/{printf " %s", $3} END{printf "\n"} ' $path_to_xml/*.xml > final_table.csv Explanation: awk: use the program awk, I tested it with GNU awk 4.0.1 -F ...


4

Regarding glob expansion possibly exceeding a limit - yes and no. The shell's already running, and so it won't stop. But if you were to pass the entire globbed array as arguments to a single command, then yes, that is a definite possibility. The portable and robust way to handle this involves find... find . \! -name . -prune -name pattern -type f -exec cat ...


0

You can try this single liner for each file. The awk multiple delimiters does efficient splitting and tr concats all lines in memory , rather than on disk. for f in `ls *.xml` ; do echo $f,`grep double $f | awk -F '[<>]' '{print $3}' | tr '\n' ','`; done I can not profile this at my end - since I do not have the same data, but my hunch is ...


-1

You’re writing twice for every file. This is probably the most expensive part. You’ll instead want to try to keep the whole thing in memory, probably in an array. Then write once in the end. Look into ulimit if you start hitting memory limits. If you’re increasing this workload to 10-100x, you’re looking at maybe 10-100 GB of memory. You could batch this in ...


2

Try executing this inside your tmux session: tmux display-message -p '#S'


1

Aside from using a control code to manually restart, you might consider using a system which is specifically designed to automate this kind of procedure, that is, (re)starting a process after code changes, such as watchman. You could also use inotifywait (from inotify-tools) to notify when a file representing source code changes, and send a signal when it ...


1

If you do not want to use loops your choices are limited as it essentially precludes just automatically restarting you program again and again. Still you can at least cut out the step with ↑ by using the accept-and-hold widget. This runs the current command line (just like accept-line which is usually bound to Enter) but also pushes it onto the buffer ...


0

Ah - I didn't intend to answer my own, but I just found a good enough solution for me. Since I never need the § key anyway, and I use backticks a fair bit - marking code here for example! - I just used 'Karabiner' (download .dmg from linked page, or brew cask install karabiner) to remap that key. Then simply used my standard .tmux.conf with backtick ...


4

If you don't want rsh and rsyslog to be ever completed in any situation just add the following into .zshrc: zstyle ':completion:*' ignored-patterns 'rsh|rsyslog'


5

oh-my-zsh enable two things, which cause this behavior: AUTO_CD: If command can not execute, and command is a directory name, perform cd to that directory CDABLE_VARS: If the argument to a cd command (or an implied cd with the AUTO_CD option set) is not a directory, and does not begin with a slash, try to expand the expression as if it were preceded by a ~ ...


0

Examples as requested. Fails when attempting using bash: mintvm ~ # echo $BASH_VERSION 4.3.11(1)-release mintvm ~ # echo $ZSH_VERSION mintvm ~ # history 1 5 -su: history: too many arguments mintvm ~ # Works when using zsh: mintvm ~ # zsh mintvm# echo $BASH_VERSION mintvm# echo $ZSH_VERSION 5.0.2 mintvm# history 1 5 1 echo $BASH_VERSION 2 ...


0

Look here: Commands are first read from /etc/zshenv; this cannot be overridden. Subsequent behaviour is modified by the RCS and GLOBAL_RCS options; the former affects all startup files, while the second only affects global startup files (those shown here with an path starting with a /). If one of the options is unset at any point, any subsequent startup ...


1

A "plugin" in OMZ is just a script. You can't disable part of it without modifying the script. A workaround would be to use Antigen or Zgen, copy the script to some other location, modify it accordingly, and load it as a separate bundle. Both Antigen and Zgen are designed to support OMZ so you won't have to change anything substantive in your setup.


1

I know I'm a little late to the party, but to undo exported environment variables, you can use the env command env -i zsh env runs the command given as an argument, and -i gives it a clean environment. Hope that helps someone!


3

zstyle handles the obvious style control for the completion system, but it seems to cover more than just that. E.g., the vcs_info module relies on it for display of git status in your prompt. You can start by looking at the few explanatory paragraphs in man zshmodules in the zstyle section. You can simply invoke it to see what settings are in effect. This ...


2

In zsh, print is a built-in command. (And, in bash, printf is a built-in command.) The command, /usr/bin/print, is used to run mailcap programs. The -z switch is defined this way from the zsh manual: Push the arguments onto the editing buffer stack, separated by spaces; no escape sequences are recognized.


2

Yes, you do see the recommendation for -U often, usually paired with -z. It’s not documented in the run-help for autoload, but there is a section titled “AUTOLOADING FUNCTIONS” in the manpage for zshmisc. There it states: The usual alias expansion during reading will be suppressed if the autoload builtin or its equivalent is given the option -U. ...


0

they may be the same (check file sizes with ls -l) or /bin/zsh may be an static linked version in my debian jessie booth are the same but i could play with update-alternatives to make /bin/sh a link to /bin/zsh-static in case my system is missing any zsh link dependency i would be able to login if my shell is /bin/zsh (if it is linked to /bin/zsh-static) ...


1

You need to set default-command: set -g default-command /usr/local/bin/zsh default-shell variable only use to create a login shell, when default-command is empty - which is default value. Or you can simply change your default shell to zsh, in this case, tmux will start a login shell, instead of non-login shell.



Top 50 recent answers are included