Bash Shell: Take Control of PS1, PS2, PS3, PS4 and PROMPT_COMMAND

本文介绍了如何通过修改PS1、PS2、PS3和PS4变量来定制Bash Shell中的提示符字符串。PS1用于设置主提示符,PS2用于设置子shell提示符,默认为'>', PS3用于ksh中select命令的菜单提示符,而PS4则用于调试脚本时的命令前缀。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PS1 - to set the prompt string, ofcourse!
PS2 - to set the subshell prompt string, which by default is ">", when we enter a command half and press enter, we get the subshell prompt string which is >, then we can complete the command and press enter, it runs. We can change the > to something by modifying this var
PS3 - mostly used in ksh, this is used to define the prompt string displayed by 'select' command, which creates a menu, so in the menu, the prompt string for each option can be defined by changing this one
PS4- we can debug a shell script by putting a set -x while running it, this enables to print each command and then its results a + sign is put before each command, this "+" prompt string can be changed by defining the PS4 var.

 

http://www.thegeekstuff.com/2008/09/bash-shell-take-control-of-ps1-ps2-ps3-ps4-and-prompt_command/

 

http://pangaoyuan.iteye.com/blog/1154788

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值