zsh

ZSH: Hide computer name in terminal

余生颓废 提交于 2019-12-03 05:42:08
问题 How would I hide the computer name in the prompt while using the terminal? At the moment it shows both username and computer name like so: It would save some space by removing anwarchoukah@anwars-mbp , seeing as I actually know who I am:) 回答1: Open up .zshrc , find the line reading export PS1 or maybe export PROMPT . Remove the variable that is used for the hostname, could be %m or %M. Customizing your shell prompt By the way you can use colors, and you can also have a prompt (or some info)

map jj to Esc in inputrc (readline)

孤街浪徒 提交于 2019-12-03 05:36:43
问题 How can I map jj to Esc in inputrc so it gets picked up by apps using GNU Readline (python, mongoshell, ...) all works fine on zsh using: bindkey -M viins 'jj' vi-cmd-mode this is my current inputrc: set editing-mode vi set keymap vi # turn off the stupid bell set bell-style none $if mode=vi set keymap vi-command "gg": beginning-of-history "G": end-of-history #"jj": vi-movement-mode set keymap vi-insert "\C-w": backward-kill-word "\C-p": history-search-backward $endif 回答1: You should

Zsh & RVM woes (rvm-prompt doesn't resolve)

一个人想着一个人 提交于 2019-12-03 05:32:58
I recently saw the light and changed over to Zsh. I naturally used Oh My Zsh to configure it, as I'm noobish. So, there are several themes that have an rvm-prompt included and here is were my problems began. Everytime I load Zsh I have to rvm reload or else rvm-prompt is not resolved ( zsh: command not found: rvm-prompt ). Note that it resolves fine after I reload. Also, and in line, when I go to a directory that has its own .rvmrc (other gemset) and then I come out of it, the same problem occurs; I'm left with having to reload Zsh again. I have RVM in $PATH set. I have [[ -s "$HOME/.rvm

zsh history is too short

混江龙づ霸主 提交于 2019-12-03 05:08:04
When I run history in Bash, I get a load of results (1000+). However, when I run history the zsh shell I only get 15 results. This makes grepping history in zsh mostly useless. My .zshrc file contains the following lines: HISTFILE=~/.zhistory HISTSIZE=SAVEHIST=10000 setopt sharehistory setopt extendedhistory How can I fix zsh to make my shell history more useful? UPDATE If in zsh I call history 1 I get all of my history, just as I do in Bash with history . I could alias the command to get the same result, but I wonder why does history behave differently in zsh and in Bash. The OP has already

Is there a hook in Bash to find out when the cwd changes?

谁都会走 提交于 2019-12-03 05:06:28
问题 I am usually using zsh, which provides the chpwd() hook. That is: If the cwd is changed by the cd builtin, zsh automatically calls the method chpwd() if it exists. This allows to set up variables and aliases which depend on the cwd. Now I want to port this bit of my .zshrc to bash, but found that chpwd() is not recognized by bash. Is a similar functionality already existing in bash? I'm aware that redefining cd works (see below), yet I'm aiming for a more elegant solution. function cd() {

Z Shell “autoload” builtin - what is it good for?

雨燕双飞 提交于 2019-12-03 04:34:01
I have been using the Z shell for a while now, and I am starting to be curious. One thing I have stumbled at when writing my own functions is "autoload". According to the zshbuiltins(1) man page autoload is "equivalent to functions -u " (with an exception), which is "equivalent to typeset -f " (with an exception). However, after looking at the autlooad use of, say functions/Prompts/promptinit , I think I have an idea what it does. I think of autoload as, well, kind of "import" statement. But why is "autoload foo" superior to "source bar"? I don't get that. Marcus Borkenhagen As stated in the

How to edit path variable in ZSH

烈酒焚心 提交于 2019-12-03 04:17:16
问题 In my .bash_profile I have the following lines: PATHDIRS=" /usr/local/mysql/bin /usr/local/share/python /opt/local/bin /opt/local/sbin $HOME/bin" for dir in $PATHDIRS do if [ -d $dir ]; then export PATH=$PATH:$dir fi done However I tried copying this to my .zshrc , and the $PATH is not being set. First I put echo statements inside the "if directory exists" function and I found that the if statement was evaluating to false, even for directories that clearly existed. Then I removed the

Unable to have Bash-like C-x-e in Zsh

主宰稳场 提交于 2019-12-03 04:14:13
问题 I found the following command in Bash which Zsh does not have in the same buttons at the thread. Ctrl-x-e It opens the current input in terminal to an editor. How can you have the same command in Zsh? 回答1: I'm using it with VIM mode. Basically ESC-v (or simply v if already in command mode) opens the terminal. It is setup by: autoload -U edit-command-line zle -N edit-command-line bindkey -M vicmd v edit-command-line Here is how to setup it in emacs mode: autoload edit-command-line zle -N edit

How can I get 'git status' to always use short format?

强颜欢笑 提交于 2019-12-03 04:06:34
问题 I'd like git status to always use the short format: $ git status --short M file1 M dir/file2 ?? file_untracked3 ?? dir/file_untracked4 There doesn't seem to exist a configuration option for this, and git config --global alias.status "status --short" does not work. I haven't managed to create an alias in zsh either. How can I make git status to use the short format by default? 回答1: Starting git1.8.4 (July 2013), you can configure git status to use short by default. See commit

zsh vi mode status line

孤街浪徒 提交于 2019-12-03 03:43:51
问题 Is there a way in zsh or bash to have a status line? e.g. in VI it will let you know that you are in insert mode with -- INSERT -- Is there an eqivalent for the command line? 回答1: This has already been answered at Super User and Unix Stack Exchange. For the completeness of Stack Overflow: function zle-line-init zle-keymap-select { RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}" RPS2=$RPS1 zle reset-prompt } zle -N zle-line-init zle -N zle-keymap-select And if you want the