zsh

zsh alias -> function?

这一生的挚爱 提交于 2019-12-02 17:57:44
Suppose I have: alias gg="git grep" then stuff like: gg "int x" works, but gg int x gets complaints. Is there a way to rewrite gg as a function in zsh so that it takes all the arguments after gg, and stuffs them into a string? Thanks! gg() { git grep "$*"; } For your particular use case, this is a bad idea. git-grep is expecting a single-arg pattern . You're trying to get the shell to treat your space (between int and x) as part of the pattern. This will break quickly when you try something like: gg foo.*bar or various other things that the shell might interpret. So anything after gg really

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

独自空忆成欢 提交于 2019-12-02 17:26:09
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? VonC Starting git1.8.4 (July 2013) , you can configure git status to use short by default. See commit 50e4f757f4adda096239c1ad60499cf606bf2c6f : Some people always run ' git status -s '. The configuration variable status

RGB values of the colors in the Ansi extended colors index (17-255)

爱⌒轻易说出口 提交于 2019-12-02 16:48:15
My question is in general shell scripting with ansi colors but for reference I am using an Apple Mac OS X 10.9 Mavericks. I use "iTerm" terminal app as my default terminal but also checked with the built in "terminal" app as well. I use ZSH (5.0.7) as my default shell but also checked in BASH (3.2.51). I have been trying to find out if there is a list of the RGB values for the 256 color indexed extended fore/background Ansi escape codes that are available using esc[38;5;xm and esc[48;5;xm where x is a number from 0 to 255. I have found some scripts that print out the colors as blocks (using

cd -1, -2, -3 etc in Z shell

时光总嘲笑我的痴心妄想 提交于 2019-12-02 16:44:26
How do you set up the Z shell such that typing cd - gives you a list of previously visited paths, and cd -1, -2, -3, etc. will then take you to the directories? If you have setopt AUTO_PUSHD in your .zshrc then cd will automatically do a pushd of each directory you change to. Taking the example from ZyX: $ setopt AUTO_PUSHD $ mkdir -p 1/2/3/4 $ cd 1 $ cd 2 $ cd 3 $ cd 4 You can see a list of the directories using dirs : $ dirs -v 0 ~/1/2/3/4 1 ~/1/2/3 2 ~/1/2 3 ~/1 4 ~ To be able to tab complete the list you can use the + and - arguments with cd ( <TAB> meaning you hit the tab key): $ cd +<TAB

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

删除回忆录丶 提交于 2019-12-02 16:38:01
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? 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-command-line bindkey '^Xe' edit-command-line Use 'bindkey -e’ to to enable emacs style or ‘bindkey -v’ to

Remove function definition (unalias equivalent) [duplicate]

佐手、 提交于 2019-12-02 16:31:55
This question already has an answer here: How do I delete a shell function? 1 answer I'm currently building a program which adds to the current user's shell depending on the project he's working on, by defining per-project aliases and functions. These aliases and functions may and will certainly have the same name like for instance cdproj , which would cd to the project's root. I would like to remove previously defined aliases and functions when changing project (before (re)defining aliases and functions for the other project. I know I can remove an alias with unalias in both bash and zsh, but

Remnant characters when tab completing with ZSH

最后都变了- 提交于 2019-12-02 16:14:31
I'm using oh-my-zsh in Arch linux with the robbyrussell theme loaded. When I try to tab complete I end up with remnant characters appended to the prompt. If I delete the auto-completed characters, the remnant characters do not delete. For example, if I type in: ~ /etc then tab, it turns to ~ /e/etc/ with a list of options below. Even if I delete /etc/ , the /e remains and I'm stuck with: ~ /e I can't delete the /e . I have to execute a command to get rid of the remnant character. Any idea what is going on here? corbacho It seems I had issues with locale configuration and non UTF8 configuration

Which shortcut in Zsh does the same as Ctrl-U in Bash?

白昼怎懂夜的黑 提交于 2019-12-02 16:05:19
In Bash, when I am typing a command, I press Ctrl + U , all characters from the beginning of the line to the cursor are going to be removed. However, in zsh, if I pressed Ctrl + U , the whole line is gone. How to do the same in Zsh as in Bash? It sounds like you'd like for Ctrl + U to be bound to backward-kill-line rather than kill-whole-line , so add this to your .zshrc : bindkey \^U backward-kill-line The bindkey builtin and the available editing commands (“widgets”) are documented in the zshzle man page. 来源: https://stackoverflow.com/questions/3483604/which-shortcut-in-zsh-does-the-same-as

zsh vi mode status line

独自空忆成欢 提交于 2019-12-02 15:58:52
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? Gilles 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 indicator below the current line rather than to the right, from Unix Stack Exchange : terminfo_down_sc=

zsh: stop backward-kill-word on directory delimiter

那年仲夏 提交于 2019-12-02 15:46:57
In zsh , how can I set up the line editor such that backward-kill-word stops on a directory separator? Currently in my bash setup, if I type cd ~/devel/sandbox and then hit C-w point will be right after "devel/". In my zsh setup, point would be after "cd ". I'd like to set up zsh so it behaves similarly to bash. A quick google reveals: Backward Kill Or, perhaps a better fix: Bash Style Backward Kill For recent versions of zsh, you can simply add: autoload -U select-word-style select-word-style bash to your zshrc as described in zshcontrib(1) . Another option is to set WORDCHARS (non