zsh

How to evaluate a shell variable each time it's used

烂漫一生 提交于 2019-11-28 08:26:51
问题 Related to a similar problem I'm having: zsh not re-computing my shell prompt Is there any way to define a shell variable such that its value is calculated each time its called? for example if I do: my_date="today is $(date)" The value in my_date would be: today is Thu Aug 9 08:06:18 PDT 2012 but I want the date to be executed each time my_date is used. In the linked post, somebody recommended putting the value in single quotes: my_date='today is $(date)' but never evaluates anything, it just

bash: unable to set and use alias in the same line

南笙酒味 提交于 2019-11-28 07:57:55
问题 I would expect the second line to say foo instead of command not found : $ alias foo="echo bac" ; foo; -bash: foo: command not found $ foo bac $ Why won't the second line say foo ? Tested with the following shells, same behavior: bash 3.2.5 zsh 5.0.8 dash 0.5.9 busybox 1.25.0 回答1: The behaviour you're seeing is described in the Bash Reference Manual (emphasis mine): The rules concerning the definition and use of aliases are somewhat confusing. Bash always reads at least one complete line of

What is the reason for the weird syntax of the “case” statement in a bash/zsh script?

故事扮演 提交于 2019-11-28 07:57:44
Looking from a programmer's point of view then shell script is just another programming language, where one has to learn and conform to the rules of the language. However, I have to admit that this syntax is the weirdest style I have ever seen in a rather commonly used language. Did the shell take this syntax from an older language that it descents from? Is there a special implication / meaning in the syntax? As an example, here is a little snippet that I take from another post on SO case "$1" in start) start ;; stop) stop ;; restart) stop start ;; status) check_status ;; *) echo "Usage: $0

E185: Cannot find color scheme solarized

被刻印的时光 ゝ 提交于 2019-11-28 06:43:48
I have Solarized installed via pathogen and it's been working fine in both terminal and MacVim on my Mac. Today, I tried setting up an Ubuntu box on Linode. I just cloned my dotfiles and symlinked to my .vim and .vimrc folders (this is the same setup as I use on my local machine. Whenever I try to run vim on the Ubuntu box I get an error Error detected while processing /root/.vimrc: line 43: E185: Cannot find color scheme solarized Press ENTER or type command to continue I can tell my .vimrc is being loaded because all other setting like line numbers are working. The related lines in .vimrc

ZSH隐藏命令行前面的用户名和主机名

好久不见. 提交于 2019-11-28 03:48:18
修改 vim ~/.zshrc 文件,在文件底部增加 隐藏用户名和主机名 prompt_context() {} 只保留用户名,隐藏主机名 prompt_context() { if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then prompt_segment black default "%(!.%{%F{yellow}%}.)$USER" fi } 只保留主机名,隐藏主机名 prompt_context() { if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then prompt_segment black default "%(!.%{%F{yellow}%}.)$HOST" fi } 修改后记得执行 source ~/.zshrc 来源: https://www.cnblogs.com/ilizhu/p/11390400.html

Can a Bash tab-completion script be used in zsh?

落花浮王杯 提交于 2019-11-28 03:03:33
I have a Bash tab-completion script for Apache's Hadoop. Normally, I use zsh as my day-to-day shell. It tends to be pretty bash-like when I need it to be, but it looks like the tab-completion systems are radically different between them. Is there a simple way to "convert" the existing bash-tab-completion definitions to work in zsh? I don't want to invest a ton of time in this, but if it's easy I'd save a moderate amount of effort. From this page (dated 2010/01/05): Zsh can handle bash completions functions. The latest development version of zsh has a function bashcompinit, that when run will

Why does a cURL request return a percent sign (%) with every request in ZSH?

折月煮酒 提交于 2019-11-28 02:38:16
问题 I've noticed that the return from any cURL request in ZSH ends in a % , for example: $ curl http://textbelt.com/text -d number="555555555" -d message="hey" => { "success": true }% Why is this character being added and is there a standard method for removing it? note: ZSH is the only shell that I notice this occurring (tested in bash csh ksh sh tcsh zsh) 回答1: This is a zsh feature that prints a percent-and-newline after a command completes if that command does not already include a newline at

LINUX(UBUNTU)下的酷炫终端

帅比萌擦擦* 提交于 2019-11-28 01:25:56
网上看了一篇老外的文章,是在MAC下利用iTerm2+zsh+Powerlevel9k+Nerd Fonts 搞出来的酷炫终端, 图片是这样的: 是不是第一眼觉得高、大、上,第二眼觉得看上去有点晕。 如果你保持这种第一眼的认知,而苦于没有没有MAC,我告诉你,其实LINUX也能做出类似的效果 实验利用UBUNTU+XSHELL终端实现(理论上其它发行版也可以) 1、安装zsh linux发行版大部分默认SHELL都是bash,而不是zsh,所以第一步安装zsh z00w00@ubuntu-14:~$ sudo apt-get install zsh 正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 将会安装下列额外的软件包: zsh-common 建议安装的软件包: zsh-doc 下列【新】软件包将被安装: zsh zsh-common 升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 218 个软件包未被升级。 需要下载 2,721 kB 的软件包。 解压缩后会消耗掉 11.4 MB 的额外空间。 您希望继续执行吗? [Y/n] y 获取:1 http://cn.archive.ubuntu.com/ubuntu/ trusty-updates/main zsh-common all 5.0.2-3ubuntu6.3

解决Mac下VSCode打开zsh乱码

别等时光非礼了梦想. 提交于 2019-11-28 00:54:11
1.乱码问题 iTerm2终端使用Zsh,并且配置Zsh主题,该主题主题需要安装字体来支持箭头效果,在iTerm2中设置这个字体,但是VSCode里这个箭头还是显示乱码。 iTerm2展示如下: VSCode展示如下: 2.解决方案 2.1 字体 在字体册查找是否已经安装 Meslo LG M for Powerline 字体,如果未安装就安装一下。 2.2 VSCode中配置 使用 ⌘, 打开settings界面,搜索 terminal ,在 Font Family 中添加字体 Meslo LG M for Powerline 也可以在VSCode的settings.json文件,加入 : "terminal.integrated.fontFamily": "Meslo LG M for Powerline", 3.效果展示 欢迎大家关注😁 来源: https://my.oschina.net/u/4192650/blog/3095142

pip fails to install anything, error: invalid command 'egg_info'

给你一囗甜甜゛ 提交于 2019-11-27 23:10:06
I recently downloaded python from their website in addition to the Python version that already comes with Mac OSX. This is when I began to have problems installing packages with pip. sudo pip install -vvv pygoogle Will output the following: The directory '/Users/robot/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/Users/robot/Library/Caches/pip/http' or its parent directory is not owned by the