zsh

Stdout race condition between script and subscript

☆樱花仙子☆ 提交于 2020-01-06 08:49:17
问题 I'm trying to call a script deepScript and process its output within another script shallowScript ; it looks schematically like the following pieces of code: shallowScript.sh #!/bin/zsh exec 1> >( tr "[a-z]" "[A-Z]" ) print "Hello - this is shallowScript" . ./deepScript.sh deepScript.sh #!/bin/zsh print "Hello - this is deepScript" Now, when I run ./shallowScript.sh , the outcome is erratic : either it works as expected (very rarely), or it prints an empty line followed by the two expected

Weird behaviour with zsh PATH

时光总嘲笑我的痴心妄想 提交于 2020-01-06 02:42:26
问题 I just encourage a weird problem with zsh today. My environment is Mac OS X Yosemite, zsh 5.0.5 (x86_64-apple-darwin14.0) In .zshrc, I have manually set the PATH variable to something like export PATH="$PATH:~/.composer/vendor/bin" Try echo $PATH in terminal, the result is as expected (contained ~/.composer/vendor/bin ). Then try executing a binary from ~/.composer/vendor/bin , It'll always return me "zsh: command not found" error. Try switching to bash, echo $PATH is also as expected, have

Oh-My-Zsh的配置与使用

久未见 提交于 2020-01-05 19:05:31
什么是Shell? 相对于内核来说,Shell是Linux/Unix的一个外壳,它负责外界与Linux内核的交互,接收用户或其他应用程序的命令,然后把这些命令转化成内核能理解的语言,传给内核,内核是真正干活的,干完之后再把结果返回用户或应用程序。 简单的说,shell就是那“黑乎乎”的命令行。 Shell的分类 Linux/Unix提供了很多种Shell,不同的shell具备不同的功能,shell还决定了脚本中函数的语法,Linux中默认的shell是/bin/bash; 想知道你的系统有几种shell,可以通过以下命令查看: cat /etc/shells 显示如下: /bin/bash /bin/csh /bin/ksh /bin/sh /bin/tcsh /bin/zsh bash 这个是目前大多数Linux系统默认使用的shell,全名是BourneAgain Shell,一共有40个命令。包含的功能几乎可以涵盖shell所具有的功能,所以一般的shell脚本都会指定它为执行路径。 在 Linux 里执行这个命令和 Mac 略有不同,你会发现 Mac 多了一个 zsh,也就是说 OS X 系统预装了个 zsh,它是什么呢? zsh介绍 zsh 是一款功能强大的 shell 软件,它可以兼容 bash,并且提供了很多高效的改进。它是Linux里最庞大的一种shell

Oh-My-Zsh及主题、插件安装与配置

[亡魂溺海] 提交于 2020-01-05 19:04:39
切换zsh Manjaro linux默认安装了zsh,其他可能需要先安装 cat /etc/shells #查看本地有哪几种shell chsh -s /bin/zsh #切换到zsh 默认终端启动zsh需要在终端中进行配置 打开终端,编辑>>>>首选项>>>>命令 勾选 “运行自定义命令而不是shell” 选项 在下面的 “自定义命令” 中填写 "zsh" 安装 oh-my-zsh 配置文件 ** 注意: root用户和普通用户需要单独安装配置,即分别切换到普通和root用户安装 ** # via curl sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" # via wget sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" # 想要卸载oh-my-zsh 输入以下命令 uninstall_oh_my_zsh 更改zsh主题 vim ~/.zshrc # 修改配置文件中的 " ZSH_THEME ",例如设置为随机主题 ZSH_THEME = "random" #

$SGE_TASK_ID not getting set with qsub array grid job

限于喜欢 提交于 2020-01-04 15:16:31
问题 With a very simple zsh script: #!/bin/zsh nums=(1 2 3) num=$nums[$SGE_TASK_ID] $SGE_TASK_ID is the sun-grid engine task id. I'm using qsub to submit an array of jobs. I am following what is advised in the qsub manpage (http://www.clusterresources.com/torquedocs/commands/qsub.shtml#t) and submitting my array job as #script name: job_script.sh qsub job_script.sh -t 1-3 $SGE_TASK_ID is not being set for this array job... does anyone have any ideas why? Thanks! 回答1: Try submitting the job like

Heredoc within command substitution: error when quotes or parentheses are unbalanced (bash and zsh)

邮差的信 提交于 2020-01-04 02:45:06
问题 Consider the following obfuscated script intended for printing a single quote, which works on ksh : #!/bin/ksh echo "$(cat <<EOF ' EOF )" Output: ' However, when I run the same script with bash 3.2.51(1) on OS X, #!/bin/bash echo "$(cat <<EOF ' EOF )" bash reports the following errors: ./heredoc-within-cmdsubst: line 3: unexpected EOF while looking for matching `'' ./heredoc-within-cmdsubst: line 6: syntax error: unexpected end of file And run with zsh 5.0.2 , #!/bin/zsh echo "$(cat <<EOF '

Mac Terminal can't run most commands after restarting it

假装没事ソ 提交于 2020-01-03 17:46:05
问题 I am using a mac. I have a customised terminal zsh , and it was fine for a while. But after I restarted my computer, it started to behave differently: The terminal stopped running commands such as rake or rails . I have already created applications using rails, but using a rails command like rails -v now gives me this: Rails is not currently installed on this system. To get the latest version, simply type: The terminal used to display a tilde ~ instead of my username and that has also stopped

Git: Getting total numbers of uncomitted lines in a repo

て烟熏妆下的殇ゞ 提交于 2020-01-02 07:07:03
问题 Is there a command to get just total number of lines that are changed in current git repo. I want to take count considering both staged and unstaged files. This is the closest I could get $ git diff --cached --shortstat 1 file changed, 1 insertion(+), 1 deletion(-) $ git diff --shortstat 1 file changed, 1 insertion(+) But I have to execute two commands and then parse (quite error prone, you never know all cases) result to find number of lines that have changed. If not a git command, a bash

Git: Getting total numbers of uncomitted lines in a repo

和自甴很熟 提交于 2020-01-02 07:06:30
问题 Is there a command to get just total number of lines that are changed in current git repo. I want to take count considering both staged and unstaged files. This is the closest I could get $ git diff --cached --shortstat 1 file changed, 1 insertion(+), 1 deletion(-) $ git diff --shortstat 1 file changed, 1 insertion(+) But I have to execute two commands and then parse (quite error prone, you never know all cases) result to find number of lines that have changed. If not a git command, a bash

Multi-dot paths in zsh, like `cd …`

☆樱花仙子☆ 提交于 2020-01-01 03:17:19
问题 All shells understand these commands: $ cd . $ cd .. And zsh will also understand: $ cd ... $ cd .... Provided you say: $ alias -g ...='../..' $ alias -g ....='../../..' Now, how can I make it do proper tab-completion when I've started typing cd ..../<TAB> ? I recall it was implemented in oh-my-zsh but I've stopped using it now. It would also be appreciated if it would work not only for cd , say I want to execute cat ..../a/b/..../c/d | less . 回答1: I wasn't happy with the other answers so I