zsh

Prevent “echo” from interpreting backslash escapes

前提是你 提交于 2019-12-29 07:15:51
问题 I'd like to echo something to a file that contains new line escape sequences, however I would like them to remain escaped. I'm looking for basically the opposite to this question. echo "part1\npart2" >> file I would like to look like this in the file $ cat file old part1\npart2 but it looks like $ cat file old part1 part2 回答1: This is a good example of why POSIX recommends using printf instead of echo (see here, under "application usage"): you don't know what you get with echo . You could get

Prevent “echo” from interpreting backslash escapes

爷,独闯天下 提交于 2019-12-29 07:15:09
问题 I'd like to echo something to a file that contains new line escape sequences, however I would like them to remain escaped. I'm looking for basically the opposite to this question. echo "part1\npart2" >> file I would like to look like this in the file $ cat file old part1\npart2 but it looks like $ cat file old part1 part2 回答1: This is a good example of why POSIX recommends using printf instead of echo (see here, under "application usage"): you don't know what you get with echo . You could get

What is the difference between alias and export (and a function!)[BASH]?

谁都会走 提交于 2019-12-29 06:55:23
问题 I'm surprised hasn't been asked before, but… What is the difference between alias ⇢ alias EXPORT='alias' function ⇢ function exporter() { echo $EXPORT } and export ⇢ export ALIAS='export' and for that matter... alias export=$(function) (j/k) in bash ( zsh , et al.) Specifically, I'd be most interested in knowing the lexical/practical difference between alias this=that and export that=this I have both forms ... all over the place - and would prefer to stop arbitrarily choosing one, over the

zsh prompt wrapping to a newline after adding buildstatus

安稳与你 提交于 2019-12-25 06:19:06
问题 I'm attempting to add my Buildkite (ci build server) project status to the zsh prompt! I've written a ruby script that pulls the status and puts it into a colon separated file in the following format: # .buildkite_status project1: √ project2: x The √ and x are ansi colour coded. And I have a prompt that works fine until I add my $ci_build variable/function to the RPROMPT! At the moment my prompt looks like; ~/.dotfiles » ± master*:3cce1cb and after the change I want ~/.dotfiles » ± master*

I/O redirection differences between zsh and bash

一笑奈何 提交于 2019-12-25 02:29:54
问题 I use zsh at the command-line but the shell scripts I write run bash so that they are portable. I was learning about IO redirection from here when I realized this difference: Note that the command is just an arbitrary one whose first line of output is over stderr and the second line comes over stdout. zsh on OS X: % ls -ld /tmp /tnt 1>&2 2>&1 | sed -e 's/^/++/' ls: /tnt: No such file or directory ++ls: /tnt: No such file or directory lrwxr-xr-x@ 1 root wheel 11 Oct 19 2012 /tmp -> private/tmp

zsh - first tab completion with autocd

情到浓时终转凉″ 提交于 2019-12-25 01:44:20
问题 I am currently switching from csh to zsh I am writing a .zshrc trying to get all the options I am used to in this new shell. I use autocd (to go into a directory just typing its name (without the cd command), and I wonder if it is possible that my first propose all the files existing in the current directory (like it's working in csh). I am quite used to this way of having an overview of the files I can open or directory I can "autocd" into, before typing my command just pressing without

Infinite recursion aliasing `cd`

瘦欲@ 提交于 2019-12-24 16:14:43
问题 I want to record my most recent cd across any one of my terminals. I thought a good way to do this would be to write a simple bash script wrapping cd : #!/bin/bash cd $1 && echo `pwd` > /tmp/.cwd Since I want the cd to occur in my terminal's process, I need to run the script with . bettercd.sh , correct? Here comes my issue: If I alias cd to this new . bettercd.sh , my shell also expands the cd inside of the script with the . bettercd.sh -- infinite recursion. Is there any way to call cd from

When using tmux nvm isn't being sourced

倖福魔咒の 提交于 2019-12-24 10:47:47
问题 I used brew to install nvm on macOS, then I used nvm to install node 8.9.1 and it works fine, until I load tmux, then I get the following messages: nvm is not compatible with the npm config "prefix" option: currently set to "/usr/local" Run `npm config delete prefix` or `nvm use --delete-prefix v8.9.1 --silent` to unset it. After some troubleshooting I noticed that when I use tmux it is using a different npm. Not using tmux: ~ which npm /Users/mario/.nvm/versions/node/v8.9.1/bin/npm ~ npm

Expand command line exclude pattern with zsh

喜夏-厌秋 提交于 2019-12-24 09:40:12
问题 I'm trying to pass a complicated regex as an ignore pattern. I want to ignore all subfolders of locales/ except locales/US/en/* . I may need to fallback to using a .agignore file, but I'm trying to avoid that. I'm using silver searcher (similar to Ack, Grep). I use zsh in my terminal. This works really well and ignores all locale subfolders except locales/US : ag -g "" --ignore locales/^US/ | fzf I also want to ignore all locales/US/* except for locales/US/en Want I want is this, but it does

Can't find pip, conda, python modules after OSX Catalina update

。_饼干妹妹 提交于 2019-12-24 03:51:21
问题 I recently updated to OSX Catalina. First thing I noticed is that the anaconda3 folder was in the 'Relocated Items' folder so I moved it to /Users/ethanfuerst/. Now, neither conda nor pip will run in my terminal. When I try to run python files, it says none of my modules are imported. I did the fix recommended here but this fix gives me this error: zsh: /Users/ethanfuerst/anaconda3/bin/conda: bad interpreter: /anaconda3/bin/python: no such file or directory What do I need to do to get my