zsh

zsh prompt and hostname

笑着哭i 提交于 2019-12-04 03:35:23
I use the following prompt in .zshrc: PROMPT="%{$fg[magenta]%}%n%{$reset_color%}@%{$fg[blue]%}%m %{$fg[yellow]%}%1~ %{$reset_color%}%# " When I open terminal I see this prompt: zoltan@zoltan-Macbook-Pro ~ % Is it possible to drop the text "zoltan" in the hostname? I would like to make it look like this: zoltan@Macbook-Pro ~ % Any suggestion would be greatly appreciated. Thank you! It's a bit of a mess, but you can pretend the %m is a parameter and use parameter expansion to strip the zoltan from the host name: PROMPT="...${${(%):-%m}#1} ..." A little explanation. First, you create a "parameter

Using curly braces referencing git revisions/references fails

家住魔仙堡 提交于 2019-12-04 03:22:54
问题 I am trying to checkout a single file from stash: git checkout stash@{0} -- some/file This fails with fatal: invalid reference: stash@0 Looks like the curly braces are eliminated, but I am not sure about the culprit. The stash revision is there. git stash list returns stash@{0}: WIP on X stash@{1}: WIP on Y I am using git 1.9.1 on zsh. Is there a way to prevent this brace elimination? 回答1: It is generally better to quote strings that contain {...} sequences (e.g., git checkout 'stash@{0}' ...

POSIX shell equivalent to <()

十年热恋 提交于 2019-12-04 03:06:58
问题 <(commands ...) in bash/zsh makes the output behavior as a file. Does a POSIX equivalent exist? 回答1: mkfifo foo.fifo ## if your "commands" is multiple commands # { commands ...; } >foo.fifo & # otherwise, if it's just one commands ... >foo.fifo & something_else foo.fifo is the closest available equivalent to something_else <( commands ... ) 来源: https://stackoverflow.com/questions/38796224/posix-shell-equivalent-to

after running program leave interactive shell to use

落爺英雄遲暮 提交于 2019-12-04 02:45:11
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. Gilles 'SO- stop being evil' 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 the script to run. However bash only does this if invoked as sh, and zsh only

Emacs: Default binary to run with M-x ansi-term

不羁的心 提交于 2019-12-04 01:45:12
Is there a way to have Emacs to prompt by default for a binary of my choice when running M-x ansi-term . It always asks me for /bin/zsh but I have a new installation of zsh in a different path. Alternatively, it would be great to have Emacs to just run the binary I want when I type M-x my-ansi-term There are a number of ways to specify the default shell: Set the variable explicit-shell-file-name . For example, in your .emacs : (setq explicit-shell-file-name "/bin/zsh") Set the environment variable ESHELL Set the environment variable SHELL phils Alternatively, it would be great to have Emacs to

ZSH auto-complete screws up command name

落花浮王杯 提交于 2019-12-04 01:22:06
问题 When I start doing tab auto-complete of a command, it keeps what I initally typed next to it and the command becomes unreadable. In the example below, I typed 'git che' and hit tab. Once I select 'checkout' the command prompt becomes 'git che git checkout'. The command still works and in my history it stores 'git checkout'. But its pretty annoying visually. Is there anyway to change this behavior. I tried this in 2 different terminal emulators, so I can confirm its ZSH and not the emulator.

gsutil returning “no matches found”

筅森魡賤 提交于 2019-12-04 00:49:23
I'm trying using gsutil to remove the contents of a Cloud Storage bucket (but not the bucket itself). According to the documentation, the command should be: gsutil rm gs://bucket/** However, whenever I run that (with my bucket name substituted of course), I get the following response: zsh: no matches found: gs://my-bucket/** I've checked permissions, and I have owner permissions. Additionally, if I specify a file, which is in the bucket, directly, it is successfully deleted. Other information which may matter: My bucket name has a "-" in it (similar to "my-bucket") It is the bucket that Cloud

Zsh Docker Plugin not Working

亡梦爱人 提交于 2019-12-03 22:12:20
I have been using oh-my-zsh for a while now and the docker plugin as recently stopped working for me for some reason. I checked my ~/.zshrc file and the plugin is included plugins=(git colored-man colorize github jira vagrant virtualenv pip python brew osx zsh-syntax-highlighting docker) I checked the ~/.oh-my-zsh/plugins/docker directory and there is a _docker file in there. Yet when I type docker and press Tab, I get none of the autocomplete shortcuts that I used to get. I can confirm that my git plugin works just fine but not the docker plugin. Tried doing exec zsh and source ~/.zshrc and

Disable auto-completion of remote branches in Zsh?

陌路散爱 提交于 2019-12-03 16:53:57
问题 This is related to Disable auto-completion of remote branches in Git Bash?. Anyone knows how to do the same with zsh? 回答1: zstyle :completion::complete:git-checkout:argument-rest:headrefs command "git for-each-ref --format='%(refname)' refs/heads 2>/dev/null" Explanation: Typing git checkout <Control-x><h> invokes _complete_help which exposes the internals of how zsh's completion system would act if you pressed TAB in the current context (instead of pressing <Control-x><h> ). From this it is

ZSH highlight on tab

断了今生、忘了曾经 提交于 2019-12-03 16:20:39
问题 One of the features that I kept hearing about zsh was that it will highlight your selection as you tab through a list of possible choices. Such as choosing a directory to cd into. I thought this feature would be enabled automatically, but it doesn't appear to be. At the moment I have this in my .zshrc for git auto completion zstyle ':completion:*:*:git:*' script /usr/local/etc/bash_completion.d/git-completion.bash fpath=(/usr/local/share/zsh-completions $fpath) autoload -U compinit &&