是否可以强制zsh在使用时回显所有别名引用的实际命令?
例如,假设我设置了以下别名:
# List direcory contents
alias lsa='ls -lah'
alias l='ls -la'
alias ll='ls -l'
Run Code Online (Sandbox Code Playgroud)
当我执行它们时,我希望看到它们中的每一个都打印出执行的实际命令.例如,我想看到以下内容:
$ ll
executing: 'ls -l'
total 0
-rw-r--r-- 1 person staff 0 Feb 15 13:46 cool.txt
-rw-r--r-- 1 person staff 0 Feb 15 13:46 sweet.html
-rw-r--r-- 1 person staff 0 Feb 15 13:46 test.md
Run Code Online (Sandbox Code Playgroud)
而不是以下:
$ ll
total 0
-rw-r--r-- 1 person staff 0 Feb 15 13:46 cool.txt
-rw-r--r-- 1 person staff 0 Feb 15 13:46 sweet.html
-rw-r--r-- 1 person staff 0 Feb 15 …Run Code Online (Sandbox Code Playgroud) 我正在尝试别名eclipse来执行eclipse -data $(pwd). 但是,由于某种原因,将此添加到我的 zshrc 中不起作用:
alias eclipse="eclipse -data $(pwd)"
我似乎找不到正确的语法 - 有人可以帮我吗?
我在.zshrc文件中的某个地方出现语法错误,我似乎无法找到它.
我收到此错误消息:
.zshrc:49: bad assignment
Run Code Online (Sandbox Code Playgroud)
这是我的.zshrc文件:
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# 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.
ZSH_THEME="robbyrussell"
# Example aliases
alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Uncomment this to disable bi-weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment to change …Run Code Online (Sandbox Code Playgroud) 我想使用后缀别名.py在 vim 中自动打开文件。为此,我已经alias -s py=vim在我的 zshrc 中。
但是,我的路径中确实有一些 python 文件是可执行文件,我想禁用后缀完成。我可以直接用 调用文件python /path/to/executable.py,但每次输入路径都很麻烦(并且反对PATH无论如何)。
有没有办法从后缀别名中免除某些文件,最好是那些不在当前工作目录中的文件?如果没有,是否有人指示如何实现这样的功能?
我刚注意到我$PATH的位置无效:
\> $PATH
zsh: no such file or directory: /usr/bin:/bin:/usr/sbin:/sbin: ...
我使用prezto并根据文档配置文件按此顺序获取:
我检查了整个清单,我找不到以前会发生的任何事情 /usr/bin
关于如何找到导致问题的原因的任何建议?
谢谢!
我想要一个能够快速将当前tmux窗口布局复制到Mac上的剪贴板的命令zsh.我想出了以下内容:
tmux list-windows | awk '{print $7}' | sed 's/\]$//' | pbcopy
Run Code Online (Sandbox Code Playgroud)
当我从命令行运行它时,它与以下输出完美配合:
d97b,135x32,0,0[135x16,0,0{87x16,0,0,0,47x16,88,0,1},135x15,0,17{87x15,0,17,2,47x15,88,17,3}]
Run Code Online (Sandbox Code Playgroud)
但是,我似乎无法将其作为别名运行.如果我添加该行:
alias layout="tmux list-windows | awk '{print $7}' | sed 's/\]$//' | pbcopy"
Run Code Online (Sandbox Code Playgroud)
.zshrc运行layout命令时,我的文件无法正常工作.它改为tmux list-windows使用layout替换会话名称的单词输出完整命令:
0: layout* (4 panes) [135x32] [layout d97b,135x32,0,0[135x16,0,0{87x16,0,0,0,47x16,88,0,1},135x15,0,17{87x15,0,17,2,47x15,88,17,3}]] @0 (active)
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
谢谢.
我正在从oh-my-zsh转换到prezto.现在每次打开终端窗口时都会遇到以下错误:
/Users/jasenlew/.zshenv:7: command not found: ^M
/Users/jasenlew/.zshenv:13: parse error near `\n'
/Users/jasenlew/.zprofile:7: command not found: ^M
/Users/jasenlew/.zprofile:11: command not found: ^M
/Users/jasenlew/.zprofile:80: parse error near `\n'
/Users/jasenlew/.zshrc:7: command not found: ^M
/Users/jasenlew/.zshrc:15: parse error near `\n'
/Users/jasenlew/.zlogin:7: command not found: ^M
/Users/jasenlew/.zlogin:15: command not found: ^M
/Users/jasenlew/.zlogin:9: command not found: ^M
/Users/jasenlew/.zlogin:12: command not found: then^M
/Users/jasenlew/.zlogin:16: command not found: ^M
/Users/jasenlew/.zlogin:21: parse error near `\n'
/Users/jasenlew/.zlogin:zcompile:13: can't open file: /Users/jasenlew/.zcompdump^M^M
/Users/jasenlew/.zlogin:14: command not found: fi^M
Run Code Online (Sandbox Code Playgroud)
我已经删除了oh-my-zsh,并按照repo/instructions安装了prezto:https://github.com/hackreactor-labs/prezto …
如果我在终端输入以下内容,我可以完成我想要的一切:
git commit -am "my commit message" ; git pull ; git push ; ssh user@server 'cd /path/to/git/repo/ ; git pull ; exit'
Run Code Online (Sandbox Code Playgroud)
我想创建与我的别名相同的~/.zshrc.就像是:
alias pushit () { git commit -am "$@" ; git pull ; git push ; ssh user@server 'cd /path/to/git/repo/ ; git pull ; exit' }
Run Code Online (Sandbox Code Playgroud)
像这样在终端中运行:
pushit "my commit message"
Run Code Online (Sandbox Code Playgroud)
相反,每当我重新加载〜/ .zshrc(source ~/.zshrc)或打开一个新的终端窗口时,我都会看到它循环遍历我的别名数十次.目前尚不清楚它实际上是在运行.
我究竟做错了什么?
笔记:
~/.zshrc).我已经添加了
export HISTIGNORE="ls:cd:pwd:exit:cd .."
Run Code Online (Sandbox Code Playgroud)
到我的.zshrc文件.
删除.zsh_history并重新启动终端,但它仍然不会忽略这些命令.
我通常使用Github作为我的dotfiles.对于我正在处理的gem,我需要为我添加一些私钥.zshrc.
有没有办法让我在我的文件中包含另一个文件.zshrc,我可以将环境变量存储在包含的文件中?