如何在KornShell中自定义显示提示显示主机名和当前目录? [英] How to custom display prompt in KornShell to show hostname and current directory?

查看:156
本文介绍了如何在KornShell中自定义显示提示显示主机名和当前目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Solaris上使用KornShell(ksh),目前我的PS1 env var是:

I am using KornShell (ksh) on Solaris and currently my PS1 env var is:

PS1 =$ {HOSTNAME} \\ $ {PWD} \ $

提示显示: hostname:/ full / path / to /当前/目录$

但是,我希望显示: hostname:directory $

换句话说,如何只显示当前目录的主机名和名称,即 tmp public_html 等等?

In other words, how can I display just the hostname and the name of the current directory, i.e. tmp or ~ or public_html etc etc?

推荐答案

从阅读 ksh手册页


PS1="${HOSTNAME}:\${PWD##*/} \$ "
Tested on default ksh on SunOS 5.8

这篇关于如何在KornShell中自定义显示提示显示主机名和当前目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆