zsh

Vim editor - zsh shell ipython magic %ed cannot find editor

為{幸葍}努か 提交于 2019-12-12 19:09:52
问题 I am trying to use the %ed magic in IPython to use vim as the editor. vim is installed ipython and ipython qtconsole both work zsh is latest as updated with my oh-my-zsh install I exported my prefernce to zsh $ echo "export EDITOR=/usr/bin/vim" >> ~/.zshrc $ echo "export VISUAL=/usr/bin/vim" >> ~/.zshrc However, when I launch IPython and then invoke the %ed magic it fails In [1]: %ed IPython will make a temporary file named: /tmp/ipython_edit_pu4Yql.py Editing.../bin/sh: 1: mvim: not found

zsh: Command substitution and proper quoting

我怕爱的太早我们不能终老 提交于 2019-12-12 16:05:44
问题 I have a script P which accepts file names as parameters: P file1 file2 file3 .... I also have a script G which generates a (typically short list) of file names, one file name per line. In a master script which I would like to write in zsh , I want to use G to generate the file names to be processed by P . The naive attempt goes like this: P $(G) This works nearly well, only that I'm living in a world where malicious people enjoy creating files with embedded spaces. If G would generate the

How to pass the contents of a file using `cat` to `_values` (zsh completion)

五迷三道 提交于 2019-12-12 13:52:00
问题 Is it possible to pass the contents of a file using cat to _values (zsh completion)? If I uncomment the line _values cat .test_tasks~ and comment _values below, it doesn't work, I get: _values:compvalues:10: invalid value definition: 1test[1 . #compdef test #autoload local curcontext="$curcontext" state line ret=1 local -a _configs _arguments -C \ '1: :->cmds' \ '2:: :->args' && ret=0 _test_tasks() { # _values "test" $(cat .test_tasks~) _values "test" \ "1test[1 test test]" \ "2test[2 test

Displaying or redirecting a shell's job control messages

主宰稳场 提交于 2019-12-12 11:11:38
问题 TL;DR All job control / crash messages are hidden when they occur within a function. I go into more detail below, but @Barmar has pointed out that this issue can be reproduced by running a crashing binary inside of a function, e.g: crun() { /tmp/faulty $1 $2 $3 } I've defined a function in my .zshrc to compile & run source code with the function below: crun() { local file=$1 shift local exepath="$(mktemp)" if [[ $file =~ "\.c$" ]]; then gcc -g -Wall $file -o $exepath || return $? else echo

Running a longer command from docker

若如初见. 提交于 2019-12-12 10:56:05
问题 I am using Docker to write a file on the fly and run it. The command looks like this so far (just to test the idea first): docker run dockerfile/python cat <<EOF >hi.txt && tail hi.txt > hi there > EOF For some reason this does not echo anything. If I run this command without a HEREDOC then it does output the result. For example the following works: docker run dockerfile/python cat > hi.txt && ls hi.txt How do I output the result of a multi line run command/HEREDOC. 回答1: I'm curious, what

Recursively deleting all “*.foo” files with corresponding “*.bar” files

徘徊边缘 提交于 2019-12-12 10:52:09
问题 How can I recursively delete all files ending in .foo which have a sibling file of the same name but ending in .bar ? For example, consider the following directory tree: . ├── dir │ ├── dir │ │ ├── file4.bar │ │ ├── file4.foo │ │ └── file5.foo │ ├── file2.foo │ ├── file3.bar │ └── file3.foo ├── file1.bar └── file1.foo In this example file.foo , file3.foo , and file4.foo would be deleted since there are sibling file{1,3,4}.bar files. file{2,5}.foo should be left alone leaving this result: . ├─

Regular expression [A-Za-z] seems to not include letter W and w

风格不统一 提交于 2019-12-12 10:23:45
问题 For some reason, I don't know why, maybe something isn't quite right in my system or in my brain, the regular expression "[A-Z]" doesn't seem to recognise the letter ”W” and "[a-z]" doesn't seem to recognise the letter ”w”. Example: for x in A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v W w X x Y y Z z; do echo $x | egrep "[A-Za-z]"; done My output is: A a B b C c D d E e F f G g H h I i J j K k L l M m N n O o P p Q q R r S s T t U u V v X x Y y Z z

How to pipe data to interactive bash script and pipe output to another command?

☆樱花仙子☆ 提交于 2019-12-12 08:57:39
问题 I'd like to pipe data into an interactive command, and have the output of the interactive command be received as input to another command. For example, I'd like to be able to do something like the following: echo "Zaphod" | hello.sh | goodbye.sh and have the output be: BYE HELLO Zaphod Here's my initial crack at this, but I'm missing something ;-) I'd actually like the hello.sh to select from a list of things. hello.sh echo Please supply your name read NAME echo "HELLO $NAME" goodbye.sh MSG=$

Emacs: Default binary to run with M-x ansi-term

吃可爱长大的小学妹 提交于 2019-12-12 08:24:44
问题 Is there a way to have Emacs to prompt by default for a binary of my choice when running M-x ansi-term . It always asks me for /bin/zsh but I have a new installation of zsh in a different path. Alternatively, it would be great to have Emacs to just run the binary I want when I type M-x my-ansi-term 回答1: There are a number of ways to specify the default shell: Set the variable explicit-shell-file-name . For example, in your .emacs : (setq explicit-shell-file-name "/bin/zsh") Set the

gsutil returning “no matches found”

巧了我就是萌 提交于 2019-12-12 08:19:39
问题 I'm trying using gsutil to remove the contents of a Cloud Storage bucket (but not the bucket itself). According to the documentation, the command should be: gsutil rm gs://bucket/** However, whenever I run that (with my bucket name substituted of course), I get the following response: zsh: no matches found: gs://my-bucket/** I've checked permissions, and I have owner permissions. Additionally, if I specify a file, which is in the bucket, directly, it is successfully deleted. Other information