zsh

bash及其特性

风格不统一 提交于 2019-11-30 18:04:36
shell是离用户最近的一个程序,也是用户直接链入计算机的外壳,shell分为GUI、CLI两种,CUI里面有gnome、KDE、Xfce,CLI里面有sh、bash、csh、ksh、zsh、tcsh。这次我们讲bash,讲之前得先弄清楚进程与程序的关系,在每个进程看来,当前主机上只存在内核和当前进程,进程是程序的副本,进程是程序执行实例。当执行bash进程,在bash里在执行一个bash进程,子bash所拥有的特性,父bash可能不可拥有,反过来也是。 bash特性 命令历史、命令补全 管道、重定向 命令别名 命令行编辑 命令行展开 文件名通配 变量 编程 命令行编辑( 光标跳转) Ctrl+a:跳到命令行首 Ctrl+e:跳到命令行尾 Crtl+d: Ctrl+u: 删除光标至命令行首的内容 Ctrl+k: 删除光标至命令行尾的内容 Ctrl+l: 清屏 ctrl+左右箭头:按单词转跳 命令历史 $ history -c:清空命令历史 -d OFFSET [n]: 删除指定位置的命令 -w:保存命令历史至历史文件中 命令默认显示1000行,可以配置环境变量,改变命令缓存的条数。可以使用echo `$HISTSIZE`查看,要修改变量可以直接修改。 命令历史的使用技巧 !n:执行命令历史中的第n条命令 !-n:执行命令历史中的倒数第n条命令 !!: 执行上一条命令 !string

Go install not working with zsh

主宰稳场 提交于 2019-11-30 17:20:34
问题 I feel like an idiot because I've installed this before on macOS and OSX but for some reason I can't see what I'm doing wrong. Please help!!! I've created a directory, ~/go , which will be my workspace. When I run go env from my home directory I get zsh: command not found: go and I know it's because of the following files. What is wrong in my configuration? ~/.bash_profile: export PATH=$PATH:/usr/local/go/bin ~/.zshrc: export PATH=$PATH:/usr/local/go/bin 回答1: Below config is working for me,

[Linux] CentOS配置终端主题 oh-my-zsh

久未见 提交于 2019-11-30 16:15:32
参照 CSDN 博主 FlowingRiver: https://blog.csdn.net/gloriaied/article/details/84645065 1、安装 zsh ,注意 zsh 和 oh-my-zsh 不是同一个软件: # yum install zsh 2、测试: $ zsh -version 3、安装 oh-my-zsh(此处需要注意普通用户安装的 root 用户用不了,反之亦然,所以要想每个用户都用,请分别安装。): curl方法 $ sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" wget方法 $ sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)" 4、配置主题 # vim ~/.zshrc 将其中的 ZSH_THEME=" xxxxxxx " 改成 ZSH_THEME=" ys " 然后保存退出(这个……百度) 这个表示应用 ys 这个主题包,也可以用其他的主题包。 5、重启终端就可以看到主题已经变了。 来源: https://www.cnblogs.com/ExileRiven/p

Alter $PATH in vim/macvim so as to find the right ruby binary

喜你入骨 提交于 2019-11-30 15:52:08
In trying to harmonize environments between a ZSH session and the vim/macvim access of the shell, a which ruby from the shell shows $HOME/.rvm/rubies/ruby-1.9.3/bin/ruby , which is good, while from inside vim/macvim a !which ruby shows /opt/local/bin/ruby , which is bad. I thought copying the invocation of RVM from .zshrc to .zshenv would work but doing so interferes with other utilities. After several days trying to sort this out, I feel stumped. Any suggestions of where documentation to resolve this can be found would be most appreciated. I don't know if it applies to zsh but depending on

Custom zsh completion for a function based on default arguments

本秂侑毒 提交于 2019-11-30 15:47:22
How can I setup completion for a function, based on existing completion definitions and default arguments. A simplified example (which could be rewritten as an alias): gpl() { git pull origin $@ } This should have the same completion as after git pull origin . compdef -e 'words[1]=(git pull origin); service=git; (( CURRENT+=2 )); _git' ggl This massages the $words , $service and $CURRENT vars used by the completion system, and then calls the _git completion function. (Thanks to Mikachu on #zsh). 来源: https://stackoverflow.com/questions/27226716/custom-zsh-completion-for-a-function-based-on

MacOS上zsh环境设置默认jdk

断了今生、忘了曾经 提交于 2019-11-30 12:28:46
进入home目录 cd ~ 修改.zprofile文件 vi .zprofile 按i进入vim插入模式,添加以下代码 export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home" export PATH="$PATH:$JAVA_HOME/bin" 键入:wq保存并退出vim 其中JAVA_HOME要对应自己电脑上安装的位置 执行source .zprofile source .zprofile 来源: https://www.cnblogs.com/wozixiaoyao/p/11586233.html

Count length of user-visible string for zsh prompt

痞子三分冷 提交于 2019-11-30 12:25:17
问题 I'd like to put my current git branch into my multi-line ZSH prompt. However, this messes up the two lines - I'd like them to line up nicely. ┌─(simont@charmander:s000)─[master *]──────────────── ───(~ )─┐ └─(127:15:44)── ──(Sat,May12)─┘ should be: ┌─(simont@charmander:s000)─[master *]─────────(~ )─┐ └─(127:15:44)── ──(Sat,May12)─┘ The git branch is grabbed from an oh-my-zsh function, git_prompt_info() , which gives me the branch, dirty status, and a bunch of prompt-escapes to color things

Constantly updated clock in zsh prompt?

半腔热情 提交于 2019-11-30 11:09:49
问题 I know that I can exec a date command in my zsh prompt. However, it shows the old time; to see the current time, I have to hit <return> and get a new prompt with the current time. Is there a way to configure the zsh prompt to constantly update itself every second? 回答1: This would be .... unpleasant in a standard zsh prompt (or bash, or other shells). I suggest you'd be better off using Gnu Screen. Screen can have a status line which can show the time. Here's an example screenrc scroll down to

Zsh: Conda/Pip installs command not found

混江龙づ霸主 提交于 2019-11-30 06:20:47
问题 So I installed Anaconda and everything is working. After I installed it I decided to switch to oh-my-zsh . I am now getting: zsh: command not found: conda when trying to use pip or conda installs echo $ZSH_VERSION 5.0.5 I have added to my zshenv.sh export PATH ="/Users/Dz/anaconda/bin:$PATH" What is it that I'm missing? 回答1: As of today Nov 4, 2018 all the following methods works, install the zsh with: sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools

shell介绍,命令历史,命令补全和别名,通配符,输入输出重定向,管道符和作业控制

a 夏天 提交于 2019-11-30 05:50:51
shell介绍 可以使用 yum list |grep zsh 或者 yum list |grep ksh 这样可以搜索 zsh 和 ksh ,有需要的话可以安装 总之,默认使用的就是 .bash shell 命令历史 输入过的命令会被保存在一个文件内 在shell界面,使用 上方向键 可以往上查看之前输入过的命令 这个保存命令的文件地址在用户家目录下面 例子:root 用户的家目录就是 /root 保存过往命令的文件名称是 .bash_history 那么root用户保存过往命令的文件路径就在 /root/.bash_history 使用 history 命令就可以查看记录了多少条过往命令 上图可以看到,输入的最后一条命令是 history 序号是1003,说明.bash_history已经记录了1003条过往命令 不过 .bash_history 最多只能存储1000条命令 往上翻,可以看到,命令是从序号 4 开始的 因为记录到1003条命令,但只能存1000条命令,所以最前面的3条命令被删除了 有一个系统内置的环境变量 HISTSIZE 使用上图命令,可以看到返回的值是 1000 所以 .bash_history 最大记录的命令数量为1000 使用 history -c 命令可以清空当前 .bash_history 的内容 不过 history -c 只是清空内存中的内容