Tag Info

New answers tagged

0

Why do you want to combine all those files into one file? If you want to feed them to a program that wants stdin, you can do this: cat *.csv | prog or any of the other combination methods mentioned earlier. If the program expects a named file as input, do something like this: mkfifo p cat *.csv > p & prog p If you want one file because one file ...


1

No, it's expanded to: bundle exec rake db:drop db:create db:migrate From zsh documentation, braces expansion section: A string of the form ‘foo{xx,yy,zz}bar’ is expanded to the individual words ‘fooxxbar’, ‘fooyybar’ and ‘foozzbar’. Left-to-right order is preserved. This construct may be nested. Commas may be quoted in order to include them ...


3

For it show as those 3 lines, you'd need: $ print -rl 'bundle exec rake db:'{drop,create,migrate} bundle exec rake db:drop bundle exec rake db:create bundle exec rake db:migrate x{a,b}y creates 2 arguments where {a,b} is replaced with a in the first and b in the second. If you wanted the above to be executed, you could pipe it to sh (or zsh though ...


4

Well, you could always just do ~ for i (drop create migrate) echo bundle exec rake db:$i bundle exec rake db:drop bundle exec rake db:create bundle exec rake db:migrate Or ~ echo bundle exec rake db:{drop,create,migrate} bundle exec rake db:drop db:create db:migrate


2

The problem is that curl expects some normal terminal settings and zle doesn't expect you change the terminal settings. So you can write it instead: _check-gmail() { zle -I ( s=$(stty -g) # safe zle's terminal setting stty sane # sane settings for curl curl -u username --silent "https://mail.google.com/mail/feed/atom" | tr -d '\n' ...


0

One approach would be to prompt the user prior to running your _check-gmail function so that your script has the password in hand, in a variable. Then you'd pass the password variable into your function so that the curl command can make use of it. For example: $ tst_fun () { echo "Parameter #1 is $1"; } $ tst_fun "my_pass" Parameter #1 is my_pass $ To ...


1

The array is defined in the shell interpreting your script, not the one running in your screen terminal window. To pass it to your screen window's zsh, try: screen -S "MYSCREEN" -p 0 -X stuff "$(typeset -p bkgarr)"$'\r' Note that it will send the newline characters as newline characters, not as carriage returns. That should be fine with zsh though (just ...


2

Corrections apply automatically because they are first on a group list, before original. You can change that with zstyle ':completion:*' group-order original corrections And the result is Credit for the final solution goes to Stéphane Chazelas.


0

If you have: zstyle ':completion:*' format 'Completing %d' zstyle ':completion:*' group-name '' zstyle ':completion:*' original true Then the original is added as a possible completion (last so you can press Up) and you get a description of what's happening. For example, pressing Tab after /usr/lco: After pressing Up: You can also press Ctrl+_ or ...


1

If you have many nested fancy aliases and you are not sure what zsh is actually doing with them and in which order options are passed to command then you can always start zsh with -x option. This will print commands and arguments as they are executed. Be aware however that this option is intended rather for debugging purpose so it prints a lot of useless ...


1

Note that Ctrl-Alt-E in bash does not only expand aliases. It also expands variables, command substitution (!), process substitution (!), arithmetic expand and removes quotes (it doesn't do filename generation (globbing) or tilde expansion). It doesn't always manage to expand aliases. So while it has its uses, it's important to realise its outcome ...


1

If you stuff a command line into a function definition and then print out the function, the aliases will be expanded. You'll also get normalized whitespace. % alias foo='bar -1' % alias bar='qux -2' % f () foo -3 % which f f () { qux -2 -1 -3 } To put all this into an interactive command, you can make a zle widget. You can define a function ...


0

I had the following error: /Users/frankus/.zshrc:source:50: no such file or directory: /Users/frankus/.oh-my-zsh^M/oh-my-zsh.sh I fixed it by renaming the oh-my-zsh folder mv ~/.oh-my-zsh^M ~/.oh-my-zsh


5

setopt extendedglob cat <->.csv > all.csv Where <-> matches any positive integer decimal number, will concatenate all those (in lexical order, which for 0 padded numbers is the same as numerical order) into all.csv. That will double the space on disk though. If you don't intend to keep the original files, you could do: for i in ...


2

If you use redirection, that will either append or overwrite contents to one file. If you want to append to one file, use: cat file.csv file2.csv file3.csv >> all.csv This next command will overwrite to all.csv: cat file.csv file2.csv file3.csv > all.csv But say you want to move all CSV files to one csv in a given directory (to append to): cat ...


3

You must use "${(@k)array}", "${(k)array}" only expands to the non-empty keys: typeset -A array array=(k1 v1 k2 v2 k3 v3) for k in "${(@k)array}"; do printf "%s -> %s\n" "$k" "$array[$k]" done Then: $ zsh test.zsh k1 -> v1 k2 -> v2 k3 -> v3 You can also replace for loop with key, value expansion: printf '%s -> %s\n' "${(@kv)array}" ...


3

zsh has different parameter substitution than Bash, which is documented in man zshexpn. It supports a variety of modifiers to expansion behaviour, which are put in parentheses before the variable name: ${(X)name}. The modifier to include array keys (including for associative arrays) is k: ${(k)array} expands to the list of keys in the array, except that if a ...


1

AFAIK, ${!...} doesn't exist. I suppose you want: ${(k)array[@]}, or simply ${(k)array}. For more information, see the zshexpn(1) man page, which says for the k expansion flag: "If name refers to an associative array, substitute the keys (element names) rather than the values of the elements."


0

In zsh which is a builtin as this command reports: $ whence -w which which: builtin To execute the external command (in any shell) which, use the Full Path: $ /bin/which ls; echo $? /bin/ls 0 thus the command ls was found (an exit value of 0), and is located at /bin/ls. Inside zsh; a way (beside the one above) to search for external commands is: $ ...


1

The first thing to know, in zsh, history meaning fc -l. Then read man zshbuiltins, section about fc command: Select a range of commands from first to last from the history list. The arguments first and last may be specified as a number or as a string. A negative number is used as an offset to the current history event number. A string specifies ...


1

You can disable the PATTERN(QUALIFIERS) syntax by unsetting the bare_glob_qual option: setopt no_bare_glob_qual If the option extended_glob is set (and you should set it, the only reason not to set it is for backward compatibility with rare scripts that use unusual syntax), then there is another syntax for glob qualifiers: PATTERN(#qQUALIFIERS). So you ...


2

In zsh, history is an alias for fc -l 1, so when you do history -20 it get replaced by fc -l 1 -20 which just won't work, so instead use fc directly: ➜ ~ fc -l -20 10095 grep -R PAPER /usr/lib/locale/ 10096 man locale 10097 man 7 locale 10098 mc 10099 history 10100 history --help 10101 run-help history 10102 history 20 10103 history 1 20 10104 ...


2

Set the SH_GLOB option. setopt sh_glob From man zshoptions: SH_GLOB Disables the special meaning of (',|', `)' and '<' for globbing the result of parameter and command substitutions, and in some other places where the shell accepts patterns. If SH_GLOB is set but KSH_GLOB is not, the ...


0

Generally speaking, this is not a good idea. Consider this scenario: Session one wants to temporarily change directories, so it pushes the current directory, expecting to pop it later when it is finished with the new directory. Session two tries the same thing. Session one tries to pop its original directory off the stack, but gets session two's directory ...


1

Any sub directory to a directory containing a git repo will be identified as a git repo. I had accidentally created a git repo in / which resulted in all directories being identified as git repos.


5

You could store the brace expansion in an array, then output it in the manner of your choosing: urls=( localhost:8080/reports/{promos,promo-updates,scandown}/{130,139,142}{,-unburdened,-burdened}{,.pdf,.xls,.xlsx,.csv,.preload} ) Then printf "%s\n" "${urls[@]}" or (IFS=$'\n'; echo "${urls[*]}") The echo example looks weird because: it's run in a ...


2

The problem is the brace expansion is adding the space, and echo is adding the newline. So using single responsibility principle, handle the newline separately. echo -e localhost:8080/reports/{promos,promo-updates,scandown}/{130,139,142}{,-unburdened,-burdened}{,.pdf,.xls,.xlsx,.csv,.preload} | tr " " "\n"


13

Use printf builtin: $ printf %s\\n localhost:8080/reports/{promos,promo-updates,scandown}/{130,139,142}{,-unburdened,-burdened}{,.pdf,.xls,.xlsx,.csv,.preload} localhost:8080/reports/promos/130 localhost:8080/reports/promos/130.pdf localhost:8080/reports/promos/130.xls localhost:8080/reports/promos/130.xlsx localhost:8080/reports/promos/130.csv ...


5

This is tagged zsh, so I suggest the zsh builtin print : print -l localhost:8080/reports/{promos,promo-updates,scandown}/{130,139,142}{,-unburdened,-burdened}{,.pdf,.xls,.xlsx,.csv,.preload} -l prints arguments on separate lines.



Top 50 recent answers are included