zsh

How to show zsh function definition (like bash “type myfunc”)?

雨燕双飞 提交于 2019-12-02 14:49:49
How do I show the definition of a function in zsh? type foo doesn't give the definition. In bash: bash$ function foo() { echo hello; } bash$ foo hello bash$ type foo foo is a function foo () { echo hello } In zsh: zsh$ function foo() { echo hello; } zsh$ foo hello zsh$ type foo foo is a shell function The zsh idiom is whence , the -f flag prints function definitions: zsh$ whence -f foo foo () { echo hello } zsh$ In zsh, type is defined as equivalent to whence -v , so you can continue to use type , but you'll need to use the -f argument: zsh$ type -f foo foo () { echo hello } zsh$ And, finally,

ZSH iterm2 increase number of lines history

时光毁灭记忆、已成空白 提交于 2019-12-02 14:34:54
Not sure if this is zsh, iterm2 or the interaction between them. Trying to change the number of recallable lines in the terminal - not the command history, the output history. In .zshrc I have : HISTFILE=~/.histfile HISTSIZE=100000 SAVEHIST=100000 This seems to be ignored =( Not sure of the correct term to google, "Terminal output history?" It's not immediately obvious in the iTerm2 documentation on how to change it. open the iTerm2 preferences ⌘ + , select the Profiles tab then select the Terminal subtab Beware, changes to the Scrollback lines value take effect immediately so check Unlimited

How can you export your .bashrc to .zshrc?

£可爱£侵袭症+ 提交于 2019-12-02 14:11:51
I am trying to move to zsh from Bash. I put my .bashrc directly to my .zshrc, and it caused a lot of errors when I try to use Bash again. How can you export your .bashrc to .zshrc? Ryne Everett While lhunath's answer pushed me in the right direction, zsh does not seem to source .profile automatically. Lot's of good info on this topic can be found on this superuser post . The adaption I'm using is putting common aliases and functions in .profile and manually sourcing them as follows: .bashrc source ~/.profile .zshrc [[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile' You can't " export "

Looking for ALT+LeftArrowKey solution in zsh

柔情痞子 提交于 2019-12-02 13:54:59
I just recently switched from bash to zsh, however I miss my Alt + LeftArrowKey and Alt + RightArrowKey to go back and forth a word at a time. Right now, if I press Alt + LeftArrowKey I go back a couple of letters and then I'm stuck. I won't go any further backwards and it won't back to the end of the line with Alt + RightArrowKey as I would expect. I can't even use the arrow keys to go to the end of the line, only to the second to last. Can't input new chars on the line either or indeed delete. How do I get my beloved shortcut back? I'm on Mac OS X using Terminal if that's important. lolesque

zsh compinit: insecure directories

偶尔善良 提交于 2019-12-02 13:50:34
What does it mean and how can I fix it? zsh compinit: insecure directories, run compaudit for list. Ignore insecure directories and continue [y] or abort compinit [n]? Running the compaudit returns the follows: There are insecure directories: /usr/local/share/zsh/site-functions chakrit This fixed it for me: $ cd /usr/local/share/zsh $ sudo chmod -R 755 ./site-functions Credit: a post on zsh mailing list EDIT: As pointed out by @biocyberman in the comments. You may need to update the owner of site-functions as well: $ sudo chown -R root:root ./site-functions On my machine (OSX 10.9), I do not

How do I update zsh to the latest version?

泪湿孤枕 提交于 2019-12-02 13:49:29
I recently switched to zsh on my Terminal.app on my OS X machine successfully. The version number of zsh is 4.3.11. Mike Li If you have Homebrew installed, you can do this. # check the zsh info brew info zsh # install zsh brew install --without-etcdir zsh # add shell path sudo vim /etc/shells # add the following line into the very end of the file(/etc/shells) /usr/local/bin/zsh # change default shell chsh -s /usr/local/bin/zsh Hope it helps, thanks. ayush narula If you're using oh-my-zsh Type upgrade_oh_my_zsh in the terminal If you're not using Homebrew, this is what I just did on MAC OS X

Switching from zsh to bash on OSX, and back again?

独自空忆成欢 提交于 2019-12-02 13:48:47
So Im learning to develop in Rails, and have discovered the power of zsh. However, for some of my other tasks, I wish to use normal Bash. Although they are the same, I just feel comfortable with the lay out of bash in some situations. How do I switch back and forth, or turn zsh on and off? Thanks! You can just use exec to replace your current shell with a new shell: Switch to bash : exec bash Switch to zsh : exec zsh This won't affect new terminal windows or anything, but it's convenient. wanghao you can try chsh -s /bin/bash to set the bash as the default, or chsh -s /bin/zsh to set the zsh

Worth switching to zsh for casual use? [closed]

社会主义新天地 提交于 2019-12-02 13:47:42
The default shell in Mac OS X is bash , which I'm generally happy to be using. I just take it for granted. It would be really nice if it auto-completed more stuff , though, and I've heard good things about zsh in this regard. But I don't really have the inclination to spend hours fiddling with settings to improve my command line usage by a tiny amount, since my life on the command line isn't that bad. (As I understand it, bash can also be configured to auto-complete more cleverly. It's the configuring I'm not all that keen on.) Will switching to zsh , even in a small number cases, make my life

ZSH print '%' automatically after the result of the C program [closed]

。_饼干妹妹 提交于 2019-12-02 13:13:16
This is a simple C program: This is the result of that program -- note the % at the end. zsh prints a % (by default for a normal user) when the last line does not end with a newline character. This partial line could be erased by the prompt otherwise. Add a newline to properly terminate the last line ( \n ): printf("1\n"); http://zsh.sourceforge.net/Doc/Release/Options.html#index-PROMPT_005fSP 来源: https://stackoverflow.com/questions/50918949/zsh-print-automatically-after-the-result-of-the-c-program

What is the zsh equivalent of a bash script getting the script's directory?

旧街凉风 提交于 2019-12-02 13:09:00
问题 I want to translate this bash-script intro a zsh-script. Hence I have no experience with this I hope I may get help here: bash script: SCRIPT_PATH="${BASH_SOURCE[0]}"; if([ -h "${SCRIPT_PATH}" ]) then while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done fi pushd . > /dev/null cd `dirname ${SCRIPT_PATH}` > /dev/null SCRIPT_PATH=`pwd`; popd > /dev/null What I already know is that I can use SCRIPT_PATH="$0"; to get the path were the script is located at. But then I get