zsh

How can I format the output of a bash command in neat columns

丶灬走出姿态 提交于 2019-11-27 10:55:44
I have a function which outputs many rows of information which I want to format in columns. The problem is that the width of any particular "cell" (if I may use that term) of data is variable, so piping it to something like awk does not give me what I want. The function is "keys" (not that it matters) and I'm trying something like this: $ keys | awk '{ print $1"\t\t" $2 }' but the output (a snippet of it, that is) looks like this: "option-y" yank-pop "option-z" execute-last-named-cmd "option-|" vi-goto-column "option-~" _bash_complete-word "option-control-?" backward-kill-word "control-_" undo

${BASH_SOURCE[0]} equivalent in zsh?

旧巷老猫 提交于 2019-11-27 10:42:14
问题 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

Run vim command from commandline

橙三吉。 提交于 2019-11-27 10:15:51
问题 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? 回答1: 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

To get a prompt which indicates Git-branch in Zsh

霸气de小男生 提交于 2019-11-27 09:46:03
问题 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

Conda command not found

强颜欢笑 提交于 2019-11-27 09:40:19
问题 I've installed Miniconda and have added the environment variable export PATH="/home/username/miniconda3/bin:$PATH" to my .bachrc and .bash_profile but still can't run any conda commands in my terminal. Am I missing another setup? I'm using zsh by the way. 回答1: If you're using zsh and it has not been set up to read .bashrc, you need to add the Miniconda directory to the zsh shell PATH environment variable. Add this to your .zshrc : export PATH="/home/username/miniconda/bin:$PATH" Make sure to

Linux命令之rpm

若如初见. 提交于 2019-11-27 09:27:55
 rpm是一个包管理器,用于生成、安装、查询、核实、更新以及卸载单个软件包。一个包通常包括一个文件存档以及元数据,用于安装和删除存档文件。元数据包括助手脚本、文件属性和包的描述信息。   必选选择以下基本模式之一:查询,验证,安装/升级/刷新/重新安装,卸载,设置所属主/所属组,显示查询标签和显示配置。 查询和验证包: rpm {-q|--query} [select-options] [query-options] rpm {-V|--verify} [select-options] [verify-options] 安装/升级/卸载包: rpm {-i|--install} [install-options] PACKAGE_FILE … rpm {-U|--upgrade} [install-options] PACKAGE_FILE … rpm {-F|--freshen} [install-options] PACKAGE_FILE … rpm {-e|--erase} [--allmatches] [--justdb] [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME … 杂项: rpm {--querytags|--showrc} rpm {--setperms|--setugids}

RVM is not working in ZSH

萝らか妹 提交于 2019-11-27 09:03:06
问题 I'd like to try out the ZSH shell on my Mac, but I also do a lot of Ruby and Rails development, so I use RVM quite a bit too. The problem is that I can't seem to get RVM to work in ZSH, and it's working fine in the default Bash shell: > zsh > rvm 1.9.2 > ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] > which ruby /usr/bin/ruby I can definitely confirm that RVM is installed, as well as ruby 1.9.2 under RVM; I use it all the time in Bash. Running an rvm list in ZSH shows

Check if current directory is a Git repository

梦想的初衷 提交于 2019-11-27 09:02:23
问题 I am writing a series of scripts for Git management in zsh. How do I check if the current directory is a Git repository? (When I'm not in a Git repo, I don't want to execute a bunch of commands and get a bunch of fatal: Not a git repository responses). 回答1: Copied from the bash completion file the following is a naive way to do it # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org> # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). # Distributed under the GNU

Complex Git branch name broke all Git commands

柔情痞子 提交于 2019-11-27 08:58:01
问题 I was trying to create a branch from master with the following command, git branch SSLOC-201_Implement___str__()_of_ProductSearchQuery when Git suddenly stopped responding. I suspect the unescaped () are to blame, somehow. Now, whenever I try to run any Git command, I get the same error: git:176: command not found: _of_ProductSearchQuery with the number after git increasing every time I type a command. Can anyone explain what happened? And how do I get back to normal? I'd like to delete that

How do I get IntelliJ Terminal to work properly with Oh My Zsh?

这一生的挚爱 提交于 2019-11-27 07:47:53
问题 I love Oh My Zsh, but it has never worked properly in the JetBrains product's Terminals: cannot find executables cannot use version managers like pyenv, sdkman, rvm Oh My Zsh is zsh shell augmentation, so the actual problem could be reduced to just getting zsh to work properly. I have tried toggling all of the Terminal config options (individually and en masse) after reading some intellij issues, to an avail. ref: https://github.com/robbyrussell/oh-my-zsh 回答1: Can't find binaries, can't run