zsh

超实用!K8s 开发者必须知道的 6 个开源工具

喜你入骨 提交于 2019-11-29 08:24:18
文章来源:云原生实验室, 点击查看原文 。 导读 :Kubernetes 作为云原生时代的“操作系统”,熟悉和使用它是每名用户(User)的必备技能。如果你正在 Kubernetes 上工作,你需要正确的工具和技巧来确保 Kubernetes 集群的高可用以及工作负载的稳定运行。本篇文章将为你详细介绍 6 个实用的 Kubernetes 开源工具,千万不要错过。 前言 随着 Kubernetes 的发展和演变,人们可以从内部来驯服它的无节制行为。但有些人并不情愿干等 Kubernetes 变得易于使用,并且为已投入生产的 Kubernetes 中遇到的很多常见问题制定了自己的解决方案。 这里我们将介绍一些提高操作效率的技巧,同时列举几个比较有用的开源 Kubernetes 工具,这些工具以各种方式简化 Kubernetes,包括简化命令行交互,简化应用程序部署语法等。 kubectl 自动补全 kubectl 这个命令行工具非常重要,与之相关的命令也很多,我们也记不住那么多的命令,而且也会经常写错,所以命令自动补全是很有必要的,kubectl 工具本身就支持自动补全,只需简单设置一下即可。 bash 用户 大多数用户的 shell 使用的是 bash ,Linux 系统可以通过下面的命令来设置: $ echo "source <(kubectl completion bash)"

How to tail -f the latest log file with a given pattern

为君一笑 提交于 2019-11-29 08:18:20
问题 I work with some log system which creates a log file every hour, like follows: SoftwareLog.2010-08-01-08 SoftwareLog.2010-08-01-09 SoftwareLog.2010-08-01-10 I'm trying to tail to follow the latest log file giving a pattern (e.g. SoftwareLog*) and I realize there's: tail -F (tail --follow=name --retry) but that only follow one specific name - and these have different names by date and hour. I tried something like: tail --follow=name --retry SoftwareLog*(.om[1]) but the wildcard statement is

What is the difference between alias and export (and a function!)[BASH]?

对着背影说爱祢 提交于 2019-11-29 06:52:44
I'm surprised hasn't been asked before, but… What is the difference between alias ⇢ alias EXPORT='alias' function ⇢ function exporter() { echo $EXPORT } and export ⇢ export ALIAS='export' and for that matter... alias export=$(function) (j/k) in bash ( zsh , et al.) Specifically, I'd be most interested in knowing the lexical/practical difference between alias this=that and export that=this I have both forms ... all over the place - and would prefer to stop arbitrarily choosing one, over the other. 😂 I'm sure there is a great reference to a "scopes and use-cases for unix shells", somewhere...

Zsh menu completion causes problems after zle reset-prompt

可紊 提交于 2019-11-29 06:21:59
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 I found this workaround, to basically prevent calling "reset-prompt" when in a menu selection : TRAPALRM() { if [ "$WIDGET" != "complete-word" ]; then zle reset-prompt fi } Note that complete-word may

Case-insensitive Glob on zsh/bash

感情迁移 提交于 2019-11-29 02:50:19
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. 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 between the parentheses and can be used multiple times. Read the manual zshexpn(1) for more information.

(转载)WSL + oh my zsh 更好看的 shell

陌路散爱 提交于 2019-11-29 02:30:45
本文转载自:https://zhuanlan.zhihu.com/p/68336685 至 win10 发布 wsl 已经有很长时间了,但是之前由于系统问题一直无法使用 wsl。昨天重置了系统终于可以尝试下这向往已久的功能了。 如何开启 wsl Windows Subsystem for Linux Installation Guide for Windows 10 我使用的是 debain,其实影响不大,下载自己喜欢的版本就好反正选择并不多 oh-my-zsh 是基于 zsh 的,比 bash 更强大更方便,同时它的主题更多更美观比如 agnoster(之前一直在mac下使用) 我的目的就是能在 wsl 使用到这样的 shell 安装 zsh 先看下自己有哪一些 shell cat /etc/shells 如果没有 zsh 需要安装 sudo apt-get install zsh #Ubuntu Linux记得先升级下 apt-get sudo yum install zsh #Redhat Linux chsh -s /bin/zsh #安装完成后设置当前用户使用 zsh 并重启 wsl 安装 oh my zsh 此时我们需要下载 oh-my-zsh sh -c "$(curl -fsSL https://raw.githubusercontent.com

ZSH: How to time a block of code?

旧巷老猫 提交于 2019-11-29 02:02:41
问题 In bash I am able to write a script that contains something like this: { time { #series of commands echo "something" echo "another command" echo "blah blah blah" } } 2> $LOGFILE In ZSH the equivalent code does not work and I can not figure out how to make it work for me. This code works but I don't exactly know how to get it to wrap multiple commands. { time echo "something" } 2>&1 I know I can create a new script and put the commands in there then time the execution properly, but is there a

Get the `pwd` in an `alias`?

微笑、不失礼 提交于 2019-11-29 01:53:19
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 always evaluates as that subdir? EDIT: not sure if this will help, but I'm using zsh via oh-my-zsh on the

How do I insert a newline/linebreak after a line using sed

◇◆丶佛笑我妖孽 提交于 2019-11-29 00:31:00
问题 It took me a while to figure out how to do this, so posting in case anyone else is looking for the same. 回答1: For adding a newline after a pattern, you can also say: sed '/pattern/{G;}' filename Quoting GNU sed manual: G Append a newline to the contents of the pattern space, and then append the contents of the hold space to that of the pattern space. EDIT: Incidentally, this happens to be covered in sed one liners: # insert a blank line below every line which matches "regex" sed '/regex/G'

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

情到浓时终转凉″ 提交于 2019-11-28 23:05: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 command whose name is the empty string, or to this: if ; then echo yes ; else echo no ; fi which is a