zsh

怎样管理 linux / mac 的配置文件

痞子三分冷 提交于 2019-12-05 21:47:06
怎样管理 linux / mac 的配置文件 在 *nix 系统中,home 目录下一般有许多程序的配置文件( rc files ),它们可以更改程序运行时的行为。 如何管理并在多台机器上分享、同步这些配置文件也算是一个棘手的问题,当然解决方法也有不少 使用 git 直接管理 home 目录 使用 git 之类的版本控制工具把整个 home 目录保存下来,这其中 ignore 文件也有两种处理方式 一种是先 ignore 所有,然后排除需要的文件 示例: cat ~/.gitignore /* !/.gitignore !/.bashrc /some_dir/* !/some_dir/sub_dir/* # ... 另一种是 ignore 不需要的文件 示例: cat ~/.gitignore /Desktop /Documents # ... 利弊 利 : 简单,直观 弊 :home 目录会显得不干净,而且每次增加、删除文件都需要更改 .gitignore 文件。 使用 symbolic link 把配置文件集中到一个 home 的子目录,比如 ~/.dotfiles ,在 home 目录创建链接到这个 .dotfiles 目录的 symbolic link ,这样只需要把这个 .dotfiles 目录使用 git 管理就好了 但是会遇到几个问题 对待同名目录,单纯 link

References to $RANDOM in subshells all returning identical values

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 20:15:30
The following short script prints a random ten-digit binary number: #!/usr/bin/zsh point='' for i in `seq 1 10` do echo $RANDOM >/dev/null point=$point`if [ $RANDOM -gt 16383 ]; then echo 0; else echo 1; fi` done echo $point However, if I remove the apparently useless echo $RANDOM >/dev/null line, the script always prints either 1111111111 or 0000000000 . Why? From the man page: The values of RANDOM form an intentionally-repeatable pseudo-random sequence; subshells that reference RANDOM will result in identical pseudo-random values unless the value of RANDOM is referenced or seeded in the

炫酷

百般思念 提交于 2019-12-05 19:54:44
yum -y install zsh#下载并安装Zshyum -y install git#下载并安装Gitsh -c "$(wget https://raw.githubusercontent.com/penndu/oh-my-zsh/master/tools/install.sh -O -)"#下载并安装Oh My Zshvim ~/.zshrc#编写配置文件ZSH_THEME="gnzh"#将引号内的内容改为gnzh robbyrussell af-magic afowler agnoster alanpeabody amuse arrow aussiegeek avit awesomepanda bira blinks bureau candy clean cloud crunch cypher dallas darkblood daveverwer dieter dogenpunk dpoggi eastwood evan fishy flazz frisk funky gallifrey gallois garyblessington gentoo geoffgarside gianu gnzh imajes jnrowe jreese jtriley juanghurtado junkfood kafeitu kardan kennethreitz kolo

after running program leave interactive shell to use

懵懂的女人 提交于 2019-12-05 19:24:01
问题 I want to run any program given as argument, through shell then want that shell left as interactive shell to use later. #!/bin/bash bash -i <<EOF $@ exec <> /dev/tty EOF But it is not working with zsh #!/bin/bash zsh -i <<EOF $@ exec <> /dev/tty EOF as well as if somebody know more improved way to do it please let me know. 回答1: Approach 1: bash, zsh and a few other shells read a file whose name is in the ENV environment variable after the usual rc files and before the interactive commands or

read all shell variables in ruby

此生再无相见时 提交于 2019-12-05 18:42:19
Problem: I'm running shell script as subprocess in ruby script, after running script I want to have an option to check all environment variables of the shell, including array variables. So far I have come up with: set | awk -F= 'BEGIN {v=0;} /^[a-zA-Z_][a-zA-Z0-9_]*=/ {v=1;} v==1 && $2~/^['\''\$]/ {v=2;} v==1 && $2~/^\(/ {v=3;} v==2 && /'\''$/ && !/'\'\''$/ {v=1;} v==3 && /\)$/ {v=1;} v {print;} v==1 {v=0;} ' Which quite good shows only variables, including arrays, multiline strings and filtering out functions. But this does not use the same format all the time, especially array variables are

Use preexec() to evaluate entered command

亡梦爱人 提交于 2019-12-05 13:55:49
I want to use preexec() to modify certain commands before they are run but I need to be able to evaluate the current entered command. Is there a variable that contains the entire command before it is executed? I know !! is the last command but I need the current line before it's saved to history. An example of what I want to do would probably help ls -l /root bitch And then I want preexec to see I wrote bitch at the end and replace it with sudo ls -l /root I think something like preexec() { if [[ $CURRENT_LINE =~ bitch$ ]]; then $CURRENT_LINE="sudo ${CURRENT_LINE% bitch}" fi Would work but I

How to make zsh forward-word behaviour same as in bash/emacs

梦想的初衷 提交于 2019-12-05 13:05:42
问题 zsh forward-word acts a bit different from bash/emacs, and I'd like to change that. Instead of description of all differences, let me just show you step by step behaviour of bash. I marked cursor as "^" symbol. foo bar --non-needed-param --needed-param^ M-b foo bar --non-needed-param --needed-^param M-b foo bar --non-needed-param --^needed-param M-b foo bar --non-needed-^param --needed-param M-b foo bar --non-^needed-param --needed-param M-b foo bar --^non-needed-param --needed-param M-b foo

Mac 终端每次启动都要执行 source .bash_profile

社会主义新天地 提交于 2019-12-05 06:31:25
网上说法都是 发现zsh加载的是 ~/.zshrc文件,而 ‘.zshrc’ 文件中并没有定义任务环境变量。 但是我搜索zsh找到的只有一个叫做「oh my zsh」的东西,我并没有装这个软件 还有一种说法是修改 .profile 文件,试过了,不好使 最后我在Stack Overflow上找到了答案 https://stackoverflow.com/questions/15733508/why-do-i-need-to-source-bash-profile-every-time Now that we've narrowed down the problem: Run ps -p $$ at the command line to determine that you are, in fact, using a bash shell. Realize that you are in zsh, which means you should be editing your profile in .zshrc . Copy the offending lines from .bash_profile to .zsh , OR Modify your .zshrc to directly source your .bash_profile . 执行 ps -p $$ ,发现结果是

Linux 安装并配置zsh

℡╲_俬逩灬. 提交于 2019-12-05 05:23:25
1. 安装zsh,配置agnoster主题 1.1 安装zsh $ sudo apt-get install -y zsh 1.2 安装 oh-my-zsh $ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" 1.3 安装 powerline font 字体库 $ sudo apt-get install fonts-powerline 1.4 打开zsh配置文件 ~/.zshrc ,修改主题为 agnoster 1 # Set name of the theme to load --- if set to "random", it will 2 # load a random theme each time oh-my-zsh is loaded, in which case, 3 # to know which specific one was loaded, run: echo $RANDOM_THEME 4 # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes 5 ZSH_THEME="agnoster" 1.5 将zsh设置为默认终端 $ chsh -s `which zsh` 1.6 注销,重新登陆

Mac zsh 所有命令失效

左心房为你撑大大i 提交于 2019-12-05 04:47:45
正在配置一些东西,然后zsh的所有命令不能用了。 我艹。。。。。。 然后一顿猛查,发现有个命令好使,记录一下 在命令行只想输入下面命令 PATH=/bin:/usr/bin:/usr/local/bin:${PATH} 亲测解决问题 来源: https://www.cnblogs.com/guoshuai-yangxu/p/11907188.html