zsh

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

ε祈祈猫儿з 提交于 2019-11-27 21:05:08
问题 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 #

golang杀死进程组

一个人想着一个人 提交于 2019-11-27 20:57:04
当我们想杀死一个进程及其所创建的所有子进程,我们可以使用 linux 命令 kill -- -pid 执行 tail -f ./text.log| grep -a "5t6hwhu1" >../a330fec0-f946-5e47-1be3-5c42ef040c78.tmp ⇒ ps -lf UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD STIME 501 407 323 4006 0 31 0 4337800 14192 - Ss 0 ttys000 0:00.03 /Applications/iT 8:45上午 501 411 409 4006 0 31 0 4334036 2472 - S+ 0 ttys000 0:00.85 -zsh 8:45上午 501 1421 1418 4006 0 31 0 4334036 1412 - Ss+ 0 ttys001 0:00.31 zsh -l 9:28上午 501 635 630 4006 0 31 0 4334036 1396 - Ss+ 0 ttys002 0:00.38 zsh -l 8:45上午 501 1517 323 4006 0 31 0 4347016 14192 - Ss 0 ttys003 0:00.04 /Applications/iT

Manjaro美化 配置教程

ε祈祈猫儿з 提交于 2019-11-27 18:52:34
title: manjaro的美化 date: 2019-04-24 22:59:57 tags: manjaro categories: manjaro 切换源 sudo vi /etc/pacman.conf 加入arch源 [archlinuxcn] SigLevel = Optional TrustedOnly Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch blackarch源(可以选择加入) [blackarch] SigLevel = Optional TrustAll Server = https://mirrors.ustc.edu.cn/blackarch/$repo/os/$arch 面对高校的源 [arch4edu] SigLevel = Never Server = http://mirrors.tuna.tsinghua.edu.cn/arch4edu/$arch ck源 [repo-ck] Server = http://repo-ck.com/$arch 设置国内源 选择前三个 快的 sudo pacman-mirrors -i -c China -m rank 全局更新 sudo pacman -Syyu 数据库被锁,删除 /var/lib/pacman/db.lck rm /var

Zsh menu completion causes problems after zle reset-prompt

佐手、 提交于 2019-11-27 18:03:43
问题 I have following code in my .zshrc: TMOUT=1 TRAPALRM() { zle reset-prompt } After triggering menu completion all items from menu, except highlighted one disappear after TRAPALRM triggers and when i keep navigating in menu zsh segvaults after a short time Is there any fix or workaround for this? EDIT: zsh version is 5.0.2 on Linux Mint 17 EDIT: i observe same thing on zsh version 5.0.7 on Gentoo 回答1: I found this workaround, to basically prevent calling "reset-prompt" when in a menu selection

Case-insensitive Glob on zsh/bash

≯℡__Kan透↙ 提交于 2019-11-27 17:06:34
问题 I need to list all files whose names start with 'SomeLongString'. But the case of 'SomeLongString' can vary. How? I am using zsh, but a bash solution is also welcome. 回答1: ZSH: $ unsetopt CASE_GLOB Or, if you don't want to enable case-insensitive globbing in general, you can activate it for only the varying part: $ print -l (#i)(somelongstring)* This will match any file that starts with "somelongstring" (in any combination of lower/upper case). The case-insensitive flag applies for everything

Get the `pwd` in an `alias`?

不问归期 提交于 2019-11-27 16:17:04
问题 Is there a way I can get the pwd in an alias in my .zshrc file? I'm trying to do something like the following: alias cleanup="rm -Rf `pwd`/{foo,bar,baz}" This worked fine in bash; pwd is always the directory I've cd 'd into, however in zsh it seems that it's evaluated when the .zshrc file is first loaded and always stays as my home directory. I've tested using with a really simple alias setup, but it never changes. How can I have this change, so that calling the alias from a subdirectory

Why does `if $(true) ; then … fi` succeed?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-27 14:31:55
问题 Inspired by this question: What should an if statement do when the condition is a command substitution where the command produces no output? NOTE: The example is if $(true); then ... , not if true ; then ... For example, given: if $(true) ; then echo yes ; else echo no ; fi I would think that $(true) should be replaced by the output of the true command, which is nothing. It should then be equivalent to either this: if "" ; then echo yes ; else echo no ; fi which prints no because there is no

Warning message when sourcing .vimrc

混江龙づ霸主 提交于 2019-11-27 12:56:29
问题 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

How do zsh ansi colour codes work?

南楼画角 提交于 2019-11-27 11:14:38
问题 I want to make my hostname in my terminal orange. How do I do that? 回答1: First off, I'm not sure what terminal you're using or if it will even support the color orange. Mine supports the following: Red, Blue, Green, Cyan, Yellow, Magenta, Black & White. And here's how I get colors in my terminal: You need to first load the colors using autoload . I use the following to load the colors and assign them to meaningful names #load colors autoload colors && colors for COLOR in RED GREEN YELLOW BLUE

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

拥有回忆 提交于 2019-11-27 10:58: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... 回答1: 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