Tag Info

Hot answers tagged

23

You can use brace expansions: convert -trim -density 400 this_is_a_very_long_filename_of_my_pdf_file.{pdf,png}


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.


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


5

I assume you've inadvertently trimmed the important part of your command lines out here: the URLs in question contain a ? character (or a *). ? and * are special glob matching characters to the shell. ? matches a single character in a filename, and * matches many. When zsh says: zsh: no matches found: http://myvideosite.com?video=123 it's telling you that ...


5

If you always use the same command with small variations (such as the file name), you can write a function: pdf2png() { convert -trim -density 400 "$1" "$1:r.png" } (this function is specific to zsh), and for each file your_file.pdf you want to convert: pdf2png your_file.pdf Note 1: You can write the same kind of function for other shells, but this is ...


4

This call to mogrify will create a new png file instead of overwriting the pdf - hopefully ;) mogrify -trim density 400 -format png th*.pdf for th*.pdf use the aprropriate number of characters to select the right file or better tab completion until you have the full name. This way you can make an alias to the whole command up to the png parameter.


4

Contrary to bash, zsh doesn't read .zshrc when running commands over ssh. So if you mess up your zshrc, you can always do: ssh machine mv .zshrc .zshrc.disabled from another machine to put your .zshrc out of the way. If you want to test a zshrc, you can put it in another directory and run zsh as: ZDOTDIR=/that/dir zsh to run zsh with that .zshrc (or ...


3

Consider using variables to store your filenames. They autocomplete too: f="this_is_a_very_long_filename_of_my_pdf_file" convert -trim -density 400 "$f.pdf" "$f.png" I use quotes because sometimes spaces bite. Significant benefits of this are: You can perform further operations with the value in $f, knowing it points to the right file It is the ...


2

You need to escape the special characters, e.g. $ rsync server:/var/log/foo/2014-07-06-\*.log . or $ rsync 'server:/var/log/foo/2014-07-06-*.log' . Or better, install url-quote-magic, e.g. autoload -Uz url-quote-magic zle -N self-insert url-quote-magic zstyle ':urlglobber' url-other-schema http https ftp mailto so that zsh will automatically do this ...


2

AFAICT, the only problematic widgets are: vi-backward-delete-char vi-kill-line vi-backward-kill-word So you could do zle -A kill-whole-line vi-kill-line zle -A backward-kill-word vi-backward-kill-word zle -A backward-delete-char vi-backward-delete-char


2

The issue is due to the letterSpace configuration in the .Xresources file, which sets letterSpace to -1 (or lower) like: ! /home/username/.Xresources URxvt*letterSpace: -1 Many users and blog posts will suggest changing the letterSpace option to -1 to adjust for kerning, but there seems to be a side effect in this situation where urxvt can't render the ...


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"


2

You can also use History Expansion to refer to words on the current command line: convert -trim -density 400 this_is_a_very_long_filename_of_my_pdf_file.pdf !#:$:r.png Event designator !# refers to the command line typed so far Word designator $ indicates the last word (before the expansion) Modifier r removes the file extension. This also marks the end ...


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.


1

You could do something like: alias forever='while ((1))' \ try-again='continue 2' \ ok-done='break' forever { for i ("$list[@]") { (( i == 2 )) && try-again } ok-done } Note that you need "$list[@]" instead of $list if you don't want to omit the empty elements. Not a lot more legible than: for ((i = 1; i <= $#list; ...


1

Using brace expansion cannot be beaten for this special example. However, a little more flexible is the zle widget copy-prev-shell-word, which does what it's name suggests and is handy if you want a similar argument as the previous, which cannot systematically derived from it. Bind the widget e.g. to CTRL+W: bindkey '^W' copy-prev-shell-word If you are ...


1

Another way: $ noglob rsync server:/var/log/foo/2014-07-06-*.log . From zsh man page: noglob Filename generation (globbing) is not performed on any of the words.


1

You can set up an alternative config file and invoke the shell with that. See http://stackoverflow.com/questions/2727172/how-to-load-different-zshrc-file-via-commandline-option .


1

The behavior can be reproduced with: export HISTSIZE=V= For some reason I had that in my .bashrc file. Most likely I didn't have focus in the window I thought I had, ended up adding V= without noticing it and was careless saving the file; maybe it was open in the editor - those are set to enable unlimited history. But zsh uses the parameter too. So bash ...



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