calculate_prompt1()
{
host="my-linux"
git_branch="a very very very very very very very very very very very very very very long prompt"
prompt="@$host \\w : \[$(tput bold)$(tput setab 1)$(tput setaf 7)\]${git_branch}\[$(tput sgr0)\]\$ "
export PS1="$prompt&
我有一些ascii文件,比如:
color green
color black
color yellow
os Linux
os android
os windows
os mac
drink coffee
drink water
number 1
number 0
number 100
我想做一个类似这样的表格:
color os drink number
-----------------------------------
green Linux coffee 1
black android wa
当我在Linux机器上运行bash脚本时,我们在日志中得到以下错误:
注意-我们在脚本中设置:
exec > $log 2>&1 , ( in order to send all standard error/output to $log )
错误信息:
tput: No value for $TERM and no -T specified
为了过滤这些错误消息,我们尝试在bash脚本中设置如下:
export TERM=xterm
但没有帮助
在挖掘之后,我们发现在某些情况下发生了这种情况,例如,当我们对远程机器执行ssh并通过ssh在远程计算机上运行命令时。
为
在使用内置的printf bash将字符串填充到特定宽度时,我遇到了一个"off-by-one“问题。
使用以下代码:
#!/bin/bash
# vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4:
# Only display motd if tty and not sudoing as root
[ "$PS1" ] && [ "$EUID" -ne 0 ] || return 0
# Run the entire function in its own subshel
假设我们有一个运行在linux终端上的c程序,它需要不断地打印信息。购买的同时你也要能够输入文字。这个程序有一个提示符,说program>,所以每次程序打印一些东西时,只需在回车符前添加\r,然后再次打印program>,以避免打印的信息与上一个提示符混淆,例如program>Printed information 1。
printed information 1
printed information 2
program>my input
但是,如果您在打印某些信息的同时进行写作,则当前输入的内容将包含在打印的信息中。
printed information 1
p
我正在尝试自定义bash提示符,下面是我的PROMPT_COMMAND
prompt_command() {
local time="${BLUE}\t${RESET}"
local user="${GREEN}\u${RESET}"
local hostname="${GREEN}\H${RESET}"
local current_dir="${YELLOW}\w${RESET}"
PS1="⌂ ${time} ${user}@${hostname} ${current_dir} \n ➤ "
系统: OS X 10.9.x (小牛)
目标:根据显示的页面是在默认的系统位置(/usr/share/man/…)还是包管理器安装的手册(/usr/local/share/man/…)的位置,能够更改手册使用的配色方案。
我对手册的绘制过程只有一个模糊的认识。我知道那个人把一个页面交给某种预处理器(troff?)在页面在less中显示之前会发生一些事情。但仅此而已。:/