zsh

How can I have term.el (ansi-term) track directories if using anyhting other than bash

梦想与她 提交于 2019-11-30 05:40:59
问题 When using eshell or ansi-term and bash emacs changes the default-directory variable depending on what directory you are in. So if I move to /home/user/code/project and then use ido-find-file to open a file it starts ido with the CWD. If I use ksh (my normal shell) or zsh (tried for testing) it doesnt work. Is there a setting or is this just supported under bash? Thanks 回答1: Put this in your .zshrc: chpwd() { print -P "\033AnSiTc %d" } print -P "\033AnSiTu %n" print -P "\033AnSiTc %d" The

ZSH: How to time a block of code?

為{幸葍}努か 提交于 2019-11-30 04:42:56
In bash I am able to write a script that contains something like this: { time { #series of commands echo "something" echo "another command" echo "blah blah blah" } } 2> $LOGFILE In ZSH the equivalent code does not work and I can not figure out how to make it work for me. This code works but I don't exactly know how to get it to wrap multiple commands. { time echo "something" } 2>&1 I know I can create a new script and put the commands in there then time the execution properly, but is there a way to do it either using functions or a similar method to the bash above? Zsolt Botykai Try the

How to redirect stdout+stderr to one file while keeping streams separate?

泪湿孤枕 提交于 2019-11-30 03:40:16
Redirecting stdout+stderr such that both get written to a file while still outputting to stdout is simple enough: cmd 2>&1 | tee output_file But then now both stdout/stderr from cmd are coming on stdout. I'd like to write stdout+stderr to the same file (so ordering is preserved assuming cmd is single threaded) but then still be able to also separately redirect them, something like this: some_magic_tee_variant combined_output cmd > >(command-expecting-stdout) 2> >(command-expecting-stderr) So combined_output contains the both with order preserved, but the command-expecting-stdout only gets

How do I insert a newline/linebreak after a line using sed

╄→гoц情女王★ 提交于 2019-11-30 02:56:08
It took me a while to figure out how to do this, so posting in case anyone else is looking for the same. For adding a newline after a pattern, you can also say: sed '/pattern/{G;}' filename Quoting GNU sed manual : G Append a newline to the contents of the pattern space, and then append the contents of the hold space to that of the pattern space. EDIT: Incidentally, this happens to be covered in sed one liners : # insert a blank line below every line which matches "regex" sed '/regex/G' This sed command: sed -i '' '/pid = run/ a\ \ ' file.txt Finds the line with: pid = run file.txt before ;

Changing the prompt style of a virtualenv instance with zsh

孤者浪人 提交于 2019-11-30 02:42:14
问题 I would like the change my zsh prompt style for every virtualenv instances that I use or create. My actual prompt is like this: declare PS1="%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}%3~%{$reset_color%}" When I activate a virtualenv it just adds some information before the prompt: (the name of my venv)my_prompt Do you know a way to change the colors or styles? 回答1: If you use virtualenvwrapper you can use its hooks to do this. 回答2: And you

yum更换国内源,yum下载rpm包,源码包安装

无人久伴 提交于 2019-11-30 02:41:53
yum更换国内源 从国外下载rpm包有时会很慢 所以更改为国内的下载源会快很多 进入 /etc/yum.repos.d 目录 使用 rm -f CentOS-Base.repo 删除 CentOS-Base.repo 文件 curl -O http://mirrors.163.com/.help/CentOS7-Base-163.repo 使用以上命名可以下载 CentOS7-Base-163.repo 文件到当前目录 完成后使用ls命令查看是否下载该文件成功 使用 wget 或者 curl 都可以下载163的源文件 如果系统没有安装 wget 可以先用 curl 下载 下载完成后,可以使用 yum repolist 或者 yum repolist all 查看可用的yum源 如图,可以看到图中三个源都是163.com的 yum下载rpm包 之前更换的国内源是基础的源 包含的rpm包不够多,有时候需要rpm包基础源里面没有 所以就需要增加扩展源,扩展源里面有更多的rpm包可以下载 使用 yum install -y epel-release 安装扩展源文件 如图,使用安装命令后,会多出这两个文件 epel.repo文件内有安装源地址等信息 现在使用 yum list 查看可以安装的包,就可以看到许多来自epel源的包 也可以使用 yum list |grep epel

小知识:讲述Linux命令别名与资源文件的区别

北城余情 提交于 2019-11-30 02:21:49
别名 别名是 命令 的快捷方式。为那些需要经常执行,但需要很长时间输入的长 命令 创建快捷方式很有用。语法是: alias ppp='ping www.baidu.com' 它们并不总是用来缩短长命令。重要的是,你将它们用于你经常执行的任务。可能的例子: alias update='yum update' 这样就可以只是用update来完成yum update的命令操作了 在终端中设置别名的问题是,一旦终端会话关闭,别名就会丢失。要永久设置它们,请使用资源文件。 http://cloud.yesky.com/info/332/1460300332.shtml http://www.pcpop.com/article/6054830.shtml https://www.linuxprobe.com/books 资源文件 资源文件(即 rc 文件)是在会话或进程开始时(每个用户在开启新终端窗口或启动 vim 等新程序时)加载的配置文件。对于 ZSH,资源文件是 .zshrc,对于 bash,它是 .bashrc。 要使别名成为永久别名,你可以将它们放入资源文件中。你可以使用你选择的文本编辑器编辑资源文件。这里使用 vim: vim $HOME/.zshrc 或者对于 bash: vim $HOME/.bashrc 这样我们在新建一个终端之后

Constantly updated clock in zsh prompt?

大兔子大兔子 提交于 2019-11-30 00:55:14
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? 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 "Red Hat Magazine A guide to GNU Screen" to see the sample (i'll reproduce that here) which will, when

Custom zsh completion for a function based on default arguments

最后都变了- 提交于 2019-11-29 23:06:54
问题 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 . 回答1: 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

Zsh: Conda/Pip installs command not found

冷暖自知 提交于 2019-11-29 23:02:06
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? 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/install.sh)" Not recommending brew installation for zsh: brew install zsh zsh-completions P.S: Tried with