如何讓command prompt過長時自動換行 - Linux

Puput avatar
By Puput
at 2011-08-31T11:25

Table of Contents

有時候cd到了一個名稱太長的路徑

光是command prompt就佔了螢幕的快一半(雖然我terminal字型已經調得不是很大了)

請問如何設定成當command prompt超過螢幕橫向寬度一定比例時自動換行?

我知道command prompt是由PS1這個變數決定的 但不知如何判斷command prompt佔螢幕的比例

另一個問題是PS1似乎是不變的

我的意思是 以我的PS1為例: \[\e[32;1m\]L:\[\e[34;1m\]\w>\[\e[0m\]

這PS1不會因為我cd到其他路徑而有所改變 這樣無法知道command prompt的長度

希望設計一個方法

可以用在螢幕大小不同的電腦上 而不需每次換了一台電腦就要重新設定

有任何建議嗎?

(我目前的作法是 若command prompt太長就用\換行後再打指令 但每次都要打\並不是很方便)

--
Tags: Linux

All Comments

Vanessa avatar
By Vanessa
at 2011-09-03T04:20
http://tinyurl.com/c5kvv9
Margaret avatar
By Margaret
at 2011-09-06T04:59
你可以計算你的位置到哪了啊
Faithe avatar
By Faithe
at 2011-09-08T18:11
這樣也不算寫死,要動態讀到terminal的width
Leila avatar
By Leila
at 2011-09-13T03:50
bash: $COLUMNS

分割TAR在linux上解壓縮?

Edwina avatar
By Edwina
at 2011-08-31T08:44
就小弟我閱讀得知 TAR是一個打包的程式 但是由於檔案太大 傳輸常會死機 所以我想要請問一下 如果我在XP系統下 將所要打包的檔案 用7z使用TAR格式進行分割 分割檔案檔名如下 abc.tar.001 abc.tar.002 abc.tar.003 並將檔案傳至linux系統下 有甚麼 ...

alias [change dir]

Suhail Hany avatar
By Suhail Hany
at 2011-08-31T08:42
※ 引述《mswethan (at竹北)》之銘言: : 每次cd 到別的目錄後,下個動作一定是ls,看一下該目錄內有哪些東西... : 這樣子真的很麻煩.. : cd xx ls : cd yy ls : ... : 我想要alias cd指令,使它做三個動作.. : 1. change dir : 2. c ...

CentOS iptables 問題

Freda avatar
By Freda
at 2011-08-31T02:19
我想在 CentOS 6 上跑 nginx iptables 是裝好預設的 policy 打入要加入 80 port 的指令 iptables -A INPUT -p tcp --dport 80 -j ACCEPT 按下 enter 後沒出現錯誤訊息 但連進來連不到,後來停掉 iptables 就連到了 i ...

CentOS 6 使用 VirtualBox 抓不到網路卡

Kristin avatar
By Kristin
at 2011-08-31T01:45
※ 引述《chan15 (ChaN)》之銘言: : OS: Windows 7 : 虛擬軟體:VirtualBox 4.1.2 : Linux: CentOS6 : 網路卡:Realtek 8169 : VirtualBox 網路設定為 NAT,也嘗試過其他的選項 : 但 CentOS 一直無法順利使用網路 ...

Atomeye的安裝

Ophelia avatar
By Ophelia
at 2011-08-31T01:34
最近再跑一些分子模擬的東西 需要用到ATOMEYE 安裝手冊上有提到一句 You must ensure that the and#34;xtermand#34; command is in your shell PATH and can be directly called 這個意思是說我需要先安裝 ...