zsh

Mac OS 终端利器 iTerm2

烈酒焚心 提交于 2019-12-11 15:03:11
之前一直使用 Mac OS 自带的终端,用起来虽然有些不太方便,但总体来说还是可以接受的,是有想换个终端的想法,然后今天偶然看到一个终端利器 iTerm2,发现真的很强大,也非常的好用,按照网上配置了主题什么的,还是有些坑的,这边再记录下,以便后面查阅。 1. 安装 iTerm2 下载地址:https://www.iterm2.com/downloads.html 下载的是压缩文件,解压后是执行程序文件,你可以直接双击,或者直接将它拖到 Applications 目录下。 或者你可以直接使用 Homebrew 进行安装: $ brew cask install iterm2 2. 配置 iTerm2 主题 iTerm2 最常用的主题是 Solarized Dark theme,下载地址:http://ethanschoonover.com/solarized 下载的是压缩文件,你先解压一下,然后打开 iTerm2,按 Command + , 键,打开 Preferences 配置界面,然后 Profiles -> Colors -> Color Presets -> Import ,选择刚才解压的 solarized->iterm2-colors-solarized->Solarized Dark.itermcolors 文件,导入成功,最后选择 Solarized Dark 主题

What is `-a` in a Zshell function and what does it have to do with my shell immediately exiting?

∥☆過路亽.° 提交于 2019-12-11 14:57:00
问题 I'm having an issue with my .zshrc file while using oh-my-zsh. Recently, I've started trying to be more careful about mucking with my base OS environment, so I installed Python (2 and 3) and pyenv using homebrew. While trying to configure the autocomplete for pyenv, I switched on the pyenv plugin in oh-my-zsh. This resulted in my shell shutting down during the launch. I found that I could prevent this from happening by commenting out most of the active portion of the pyenv oh-my-zsh plugin,

How do you invoke alias from ruby code for zsh shell?

送分小仙女□ 提交于 2019-12-11 13:52:29
问题 I would like to invoke alias from ruby code so as to test the alias which I programmatically inserted into the dotfile. Say for example, the alias is the following: alias something="echo somethingelse" I searched the web and found the solution for bash: #solution for bash system %( source ~/.bash_profile shopt -s expand_aliases something ) However, this does not work for zsh. I tried to invoke the alias using the following code (and a combination of other commands) but to no avail. system %(

zsh: disable default completion for `make`

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 12:49:51
问题 I wrote my auto-completion function for make command, and placed it in ~/.zsh : function __comp_make { # ... function body .... } compctl -K __comp_make make Unfortunately, it will not work because completion for make is already defined in /usr/share/zsh/functions/Completion/Unix/_make and apparently it takes precedence over my rule. I had to rename _make to unused_make so it is not loaded at zsh initialization. It works, but it is rather ugly solution. My question is: how should I set my

Removing lines from multiple files with sed command

北战南征 提交于 2019-12-11 09:04:48
问题 So, disclaimer: I am pretty new to using bash and zsh, so there is a chance the answer is really simple. Nonetheless. I checked previous postings and couldn't find anything. (edit: I have tried this in both bash and zsh shells- same problem.) I have a directory with many files and am trying to remove the first line from each file. So say the directory contains: file1.txt file2.txt file3.txt ... etc. I am using the sed command (non-GNU): sed -i -e "1d" *.txt For some reason, this is only

Why does this parameter expansion for finding the index of a single quote in a string work?

∥☆過路亽.° 提交于 2019-12-11 07:48:07
问题 I was messing around trying to extract a single quoted word from a string in zsh, and the obvious things to try didn't work, like these: ${foo[(i)']} ${foo[(i)'']} ${foo[(i)\']} When I tried that first one on the command line, it prompted me to continue the line with braceparam quote> , which I followed with another single quote, then again with braceparam> , which I followed with another closing brace. Much to my surprise, this actually gave the correct index. All joined together, this is

How can you access the second argument of the second to last command at the cli?

旧街凉风 提交于 2019-12-11 07:33:03
问题 For example: ~ echo foo bar baz foo bar baz ~ echo catz ratz batz catz ratz batz ~ echo !!:2 #=> ratz In this case the !!:2 accesses the second argument of the last command. Is it possible to get the second argument of the second to last command which in this case would expand to bar ? 回答1: As illustrated by @Jahid in a previous post: Second argument of the second to last command: ~ $ echo foo bar baz # This one is the target foo bar baz ~ $ echo catz ratz batz catz ratz batz ~ $ echo !-2:2

iTerms2 简单配置

徘徊边缘 提交于 2019-12-11 04:55:58
趁着今天那个半死不活对模型还在训着,简单配置一下Mac上的iTerms 2。之前没有感觉iTerms 2比Mac自带对终端好用在哪,不过imgcat只能在iTerms 2下用,没办法。 修改iTerms 2的颜色主题 Preference->Profiles->Colors->右下角选择 Solarized Dark 安装powerline power是一个比较常用的状态栏工具,在vim和终端命令行中比较常用,可以是iTems2变得比较炫。 pip install powerline-status 然后安装对应的字体 https://github.com/powerline/fonts/blob/master/Meslo%20Slashed/Meslo%20LG%20M%20Regular%20for%20Powerline.ttf 点击view row下载安装即可 安装oh-my-zsh zsh和bash一样,是一种shell,但是功能比较强大。oh-my-zsh是为了解决zsh配置使用过于复杂而产生的一个开源项目。 sh -c " $( curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh ) " 安装完成后可以输入命令 chsh -s /bin

Variable names in prompt instead of path

有些话、适合烂在心里 提交于 2019-12-11 04:28:39
问题 How can I prevent my zsh prompt from showing the variable name a path is assigned to instead of the path itself? foo="/some/path" cd "$foo" shows $ ~foo/ in my prompt instead $ /some/path/ 回答1: From the comments: you're seeing Named Directories. Check if AUTO_NAME_DIRS is set ( setopt | grep AUTO_NAME_DIRS ) - to disable this functionality, turn it off. 来源: https://stackoverflow.com/questions/16203555/variable-names-in-prompt-instead-of-path

How to change shell from /bin/bash to /bin/zsh?

柔情痞子 提交于 2019-12-11 03:38:39
问题 I am trying to change from /bin/bash to /bin/zsh but I get this... $ chsh Password: Changing the login shell for user_name Enter the new value, or press ENTER for the default Login Shell [/bin/bash]: /bin/zsh chsh: user 'username' does not exist in /etc/passwd $ I checked /etc/passwd, there is no entry for my username. Also, we use likewise-open for authentication on LDAP. Please help. 来源: https://stackoverflow.com/questions/30843314/how-to-change-shell-from-bin-bash-to-bin-zsh