zsh

How to get shell to self-detect using zsh or bash

北城以北 提交于 2019-11-28 22:18:39
I've a question on how to tell which shell the user is using. Suppose a script that if the user is using zsh, then put PATH to his .zshrc and if using bash should put in .bashrc. And set rvmrc accordingly. #!/usr/bin/env bash export PATH='/usr/local/bin:$PATH'" >> ~/.zshrc source ~/.zshrc I've tried the following but it does not work : ( if [[ $0 == "bash ]]; then export PATH='/usr/local/bin:$PATH'" >> ~/.bashrc elif [[ $0 == "zsh" ]]; then export PATH='/usr/local/bin:$PATH'" >> ~/.zshrc fi # ... more commands ... if [[ $0 == "bash ]]; then [[ -s '/Users/`whoami`/.rvm/scripts/rvm' ]] && source

Warning message when sourcing .vimrc

为君一笑 提交于 2019-11-28 20:28:26
I am trying to set up a .vimrc file in my home directory. The only thing it contains is the following. " Enable syntax highlighting syntax on Whenever I want to source the file running . ~/.vimrc this message is returned. /Users/username/.vimrc:3: unmatched " My working environment is the following. MacOS Lion 10.7.2 zsh 4.3.12 (i386-apple-darwin11.2.0) oh_my_zsh Terminal 2.2.1 VIM 7.3 How can I get rid of this warning/error message. What does it mean?! EDIT When I try the same from bash it does not work either. bash-3.2$ . ~/.vimrc bash: /Users/username/.vimrc: line 1: unexpected EOF while

${BASH_SOURCE[0]} equivalent in zsh?

ε祈祈猫儿з 提交于 2019-11-28 19:05:41
The title should say it all. I'm looking for an equivalent to ${BASH_SOURCE[0]} in zsh. Note: I keep finding " $0 is equivalent to ${BASH_SOURCE[0]} " around the Internet, but this seems to be false: $0 seems to be the name of the executing command. (It's argv[0] , which makes sense.) Echoing $0 in my script ( .zshrc ) gives zsh for $0 , which isn't the same as what ${BASH_SOURCE[0]} is. In fact, ${BASH_SOURCE[0]} seems to work in zsh , except for inside .zshrc files. What I'm really doing in my .zshrc (that isn't working): echo ${BASH_SOURCE[0]} source `dirname $0`/common-shell-rc.sh The

Weird character zsh in emacs terminal

孤者浪人 提交于 2019-11-28 18:51:49
问题 When using the terminal in emacs (M-x term) under MacOS for some reason it always posts the characters 4m before every line in zsh and always prints 2 lines containing the user info such as 4m--(jesus@laptop:/dir)---- 4m--(jesus@laptop:/dir)---- prompt> It's more of an annoyance than anything but I was just wondering if there's a way to fix this. I also seem to have issues in Zsh in Mac OS emacs terminal mode when a lot of output is written to it it seems to reduce it all to one line and

Getting a weird percent sign in printf output in terminal with C

别说谁变了你拦得住时间么 提交于 2019-11-28 18:48:34
问题 I have this printf statement at the end of my program: printf("%d", total_candies); total_candies is an int , and while I expect everything to work correctly, along with the actual number, I'm getting a weird percent sign at the end. Can anyone tell me why this is happening? 回答1: When (non-null) output from a program doesn't include a trailing newline, zsh adds that color-inverted % to indicate that and moves to the next line before printing the prompt; it's generally more convenient than

(zsh brace expansion | seq) for character lists - how?

倖福魔咒の 提交于 2019-11-28 18:01:30
Bash allows me to write the statement, $ for i in {h..k} ; do echo $i ; done but zsh only allows number list expansion such as {8..13} . What's the best workaround? Something like seq for characters... As this is still a top google result, an updated answer: The current release supports bash style {c1..c2} where c1 and c2 are characters: An expression of the form ‘ {c1..c2} ’, where c1 and c2 are single characters (which may be multibyte characters), is expanded to every character in the range from c1 to c2 in whatever character sequence is used internally. For characters with code points

Run vim command from commandline

ⅰ亾dé卋堺 提交于 2019-11-28 17:11:09
There are lots of SO questions on running shell programs from vim. What I'm wondering is if it is possible to do the reverse - i.e. $ vim :BundleInstall for example, to allow me to run BundleInstall as part of a script, rather than having to open Vim and run it manually on first running? Is this possible? jvc26 Note, now the syntax has changed, and the line should read (As per @sheharyar ): vim +PluginInstall +qall For posterity, previously, the correct line was: vim +BundleInstall +qall Should anyone other than me be looking! Note: this is in the Github README for vundle. I think that this is

oh-my-zsh themes don't show properly (background stays white)

拥有回忆 提交于 2019-11-28 16:55:12
问题 I am trying to figure out why my oh-my-zsh themes don't work properly. The colors show up properly, but background stays white (with black text). below is my /.zshrc file and current path variable: # Path to your oh-my-zsh configuration. ZSH=$HOME/.oh-my-zsh export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" # Set name of the theme to load. # Look in ~/.oh-my-zsh/themes/ # Optionally, if you set this to "random", it'll load a random theme each # time that oh-my-zsh is loaded. export

Fix key settings (Home/End/Insert/Delete) in .zshrc when running Zsh in Terminator Terminal Emulator

僤鯓⒐⒋嵵緔 提交于 2019-11-28 16:46:58
问题 I'm running Ubuntu 11.04. I installed the Terminator Terminal Emulator 0.95, and Zsh, version 4.3.15. I have (commonly known) problems with my keys inside the Zsh. At least these: Home/End, nothing happens Insert/Delete/PageUp/PageDown: a "~" is typed I already tried some configurations for .zshrc which should solve the problem, but no approach really worked so far. Maybe this is related to the combination of Terminator and Zsh. I took the 2 configs on this page: https://bbs.archlinux.org

To get a prompt which indicates Git-branch in Zsh

时光毁灭记忆、已成空白 提交于 2019-11-28 16:11:14
I run the following codes separately as my prompt unsuccessfully in .zshrc. This suggests me that apparently I do not have a program called __git_ps1. It is not in MacPorts. #1 PROMPT="$(__git_ps1 " \[\033[1;32m\] (%s)\[\033[0m\]")\$"$ #2 PROMPT="$(__git_ps1 " (%s)")\$"$ #3 # Get the name of the branch we are on git_prompt_info() { branch_prompt=$(__git_ps1) if [ -n "$branch_prompt" ]; then status_icon=$(git_status) echo $branch_prompt $status_icon fi } # Show character if changes are pending git_status() { if current_git_status=$(git status | grep 'added to commit' 2> /dev/null); then echo "☠