zsh

Git / detached HEAD, get work back?

好久不见. 提交于 2020-01-01 01:18:07
问题 I made a dozens of commits on what I thought was my branch, then checked out another branch. Willing to go back to my initial branch, I didn't find my updated code. After looking at my history in console, I understood I worked in a detached branch... Is it somehow possible to get the job I've done on the detached branch? 回答1: Yes. You can use the reflog. Try git log -g HEAD . This will show you the reflog for HEAD , i.e. every single commit that HEAD has pointed to, and the reason why it

bash vs csh vs others - which is better for application maintenance? [duplicate]

匆匆过客 提交于 2019-12-31 21:43:12
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: What Linux shell should I use? I am starting to get proficient in a Linux environment and i'm trying to pick a weapon of choice in terms of command shell scripting (as i'm still a big n00b at this) that will help me (and others) manage, test and administer a set of server side applications running on a *NIX environment. My question is: What is(are) the preferred command shell(s) out there when the following

What is the format of shell history files

我们两清 提交于 2019-12-31 07:27:09
问题 My ~/.zsh_history shows: : 1449561637:0;echo "foobar" I'm guessing it goes unix timestamp : exit code ; command but what about the space before the timestamp and first colon? Is there an official spec? 回答1: As already noted in the comments, the format of the history file depends on the shell and sometimes even on specific settings of the shell. In your case you are using zsh with the EXTENDED_HISTORY option enabled (either by explicitly setting it or by using csh -emulation). According to the

How can I trigger brace expansion inside a script?

别等时光非礼了梦想. 提交于 2019-12-31 01:51:12
问题 I'm writing a script which needs to use the shell's brace expansion, but nothing I've tried works. For (a contrived) instance, say I have a variable containing the string thing{01..02} and I (obviously) want to expand it to thing01 thing02 from inside the script, how can I do that? (For anyone who assumes this is a duplicate of this other question, please read them more carefully. That question is regarding working from the shell, not a shell script, and doesn't require the ability to expand

shell介绍、history历史命令及配置文件、tab补全、通配符和输出重定向

孤者浪人 提交于 2019-12-30 12:36:10
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 10月11日任务 8.1 shell介绍 8.2 命令历史 8.3 命令补全和别名 8.4 通配符 8.5 输入输出重定向 8.1 shell介绍 什么是shell shell是一个命令解释器,提供用户和机器之间的交互 支持特定语法,比如逻辑判断、循环 每个用户都可以有自己特定的shell CentOS7默认shell为bash(Bourne Agin Shell) 还有zsh/ksh等 8.2 命令历史 history命令 .bash_history 最大1000条 变量HISTSIZE /etc/prefile中修改 #vim /etc/prefile 来修改变量HISTSIZE值 HISTTIMEFORMAT="%Y/%m/%d%H:%M:%S" 永久保存 chattr +a ~/.bash_history !! #表示上一条命令 !n #表示第n条命令 !word #表示执行最后一条word命令 #查看历史命令 [root@centos6 ~]# history #历史命令变量 [root@centos6 ~]# echo $HISTSIZE 1000 #history -c清空内存中的命令历史,但不能修改配置文件 .bash_history里的内容 [root@centos6 ~]# history

23. shell介绍、历史 命令补全和别名 通配符 输入输出重定向

拜拜、爱过 提交于 2019-12-30 12:33:49
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 8.1 shell介绍 8.2 命令历史 8.3 命令补全和别名 8.4 通配符 8.5 输入输出重定向 8.1 shell介绍: shell是一个命令解释器,提供用户与机器之间的交交互 支持特定语法,不如逻辑变换、循环 每个用户都可以有自己特定的shell centos7默认shell为bash(Bourne Agin Shell) 还有zsh、ksh等 可以看一下有没有zsh ksh [root @localhost ~]# yum list |grep zsh zsh.x86_64 5.0.2-28.el7 @base autojump-zsh.noarch 22.3.0-3.el7 epel zsh-html.x86_64 5.0.2-28.el7 base zsh-lovers.noarch 0.9.0-1.el7 epel [root @localhost ~]# yum list |grep ksh ksh.x86_64 20120801-137.el7 base mksh.x86_64 46-8.el7 base python-XStatic-Rickshaw.noarch 1.5.0.0-4.el7 epel python-moksha-common.noarch 1.2.3-2.el7

shell介绍-历史命令-通配符-重定向

拜拜、爱过 提交于 2019-12-30 12:05:09
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> shell 是一个命令解释器,提供用户和机器之间的交互 支持语法:逻辑判断,循环 每个用户有自己特定的shell centos7默认bash:/bin/bash 还有zsh,ksh等 history /家目录/.bash_history文件保存输入过的命令历史 默认最大记录1000条,可由环境变量HISTSIZE进行更改,或在/etc/profile文件修改对应值 命令历史存在于内存,当正常退出终端后才会保存到.bash_history文件里 history -c 清空内存里的命令历史,不会清空.bash_history文件 命令历史添加命令执行的时间:修改环境变量HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S " (默认无此变量,或者="%F %T ");将变量赋值添加到.bash_history 永久保存历史文件:chattr +a ~/.bash_history !n:n为数字,执行命令历史中第n条命令 !xxx:命令历史从后往前执行第一次匹配到的以xxx开头的命令 [tab]键敲一下可补全命令名称,或路径、文件名称。 [tab]键敲两下可列出所有待补全的项 安装bash-completion可实现命令参数补全 保存alsia别名系统文件:~/.bashrc;/etc/profile

如何基于通配符匹配递归地找到当前文件夹和子文件夹中的所有文件?

こ雲淡風輕ζ 提交于 2019-12-30 09:48:52
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 如何基于通配符匹配递归地找到当前文件夹和子文件夹中的所有文件? #1楼 用管道发现grep通常更方便; 它为您提供了用于任意通配符匹配的正则表达式的全部功能。 例如,要查找文件名中不区分大小写的字符串“ foo”的所有文件: ~$ find . -print | grep -i foo #2楼 如果您的外壳支持 新的通配选项 (可以通过以下方式启用: shopt -s globstar ),则可以使用: echo **/*foo* 递归查找任何文件或文件夹。 Bash 4,zsh和类似的shell支持此功能。 我个人已经定义了这个shell函数: f() { find . -name "*$1*"; } 注意:以上行可以直接粘贴到shell或添加到用户的 ~/.bashrc 文件中。 然后,我可以通过键入以下内容查找任何文件: f some_name 或者,您可以使用具有简单语法的 fd 实用程序 ,例如 fd pattern 。 #3楼 find -L . -name "foo*" 在某些情况下,我需要-L参数来处理符号目录链接。 默认情况下,符号链接被忽略。 在那些情况下,这很令人困惑,因为我会将目录更改为子目录,并查看与模式匹配的文件,但是find不会返回文件名。 使用-L解决了该问题。

zsh禁用共享命令记录

时光总嘲笑我的痴心妄想 提交于 2019-12-29 21:55:34
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 转载请注明文章出处: https://tlanyan.me/zsh-disable-share-history zsh默认启用了命令记录(history)共享。打开多个终端tab,在某个tab中输入命令,该命令记录会马上共享到其他tab,然后设置为最后一条命令(按上箭头⬆️就能看到)。因本人长期使用多个终端同时操作,这个特性会打断同一终端历史命令的连续性,所以非常讨厌这个特性。 这是zsh的特性,和oh my zsh无关。禁用共享命令记录也很简单,在~/.zshrc末尾加入如下设置: setopt no_share_history 关掉终端重新打开或者重新加载.zshrc文件,烦人的历史命令同步问题就解决了。 参考 https://github.com/ohmyzsh/ohmyzsh/issues/2537 来源: oschina 链接: https://my.oschina.net/u/1030865/blog/3149321

NPM Command Not Found After Installing Node

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 20:41:11
问题 I am having a very hard time getting the npm command to work, and unfortunately my knowledge of unix isn't good enough to solve this on my own. All I've done is brew install node , and I get the following errors: When I type npm I get zsh: command not found: npm Looking into this issue more I found this stack overflow answer: Command not found after npm install in zsh Following its advice I tried adding export PATH=/usr/local/share/npm/bin:$PATH to my .zshrc file. Still get the same error