2015-05-19 19 views
5

Bir dizine daha derine indiğimde, zsh komut isteminde tam yolu görüntüler. Bunun yerinezsh, geçerli yolun uzunluğunu kısaltır

[email protected]:~/i/am/a/really/really/really/really/long/path/somewhere

görüntüleme

Doğrusu ben bunu başarabilirsiniz nasıl

[email protected]:~/path/somewhere

istiyorum?

OSX Yosemite 10.10.4 üzerinde iTM ile iTM kullanıyorum.

DÜZENLEME:

İşte benim bashrc'de-dosyasıdır:

1 # System-wide .bashrc file for interactive bash(1) shells. 
    2 if [ -z "$PS1" ]; then 
    3 return 
    4 fi 
    5 
    6 PS1='\h:\W \u\$ ' 
    7 # Make bash check its window size after a process completes 
    8 shopt -s checkwinsize 
    9 # Tell the terminal about the working directory at each prompt. 
    10 if [ "$TERM_PROGRAM" == "Apple_Terminal" ] && [ -z "$INSIDE_EMACS" ]; then 
    11  update_terminal_cwd() { 
    12   # Identify the directory using a "file:" scheme URL, 
    13   # including the host name to disambiguate local vs. 
    14   # remote connections. Percent-escape spaces. 
    15   local SEARCH=' ' 
    16   local REPLACE='%20' 
    17   local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}" 
    18   printf '\e]7;%s\a' "$PWD_URL" 
    19  } 
    20  PROMPT_COMMAND="update_terminal_cwd; $PROMPT_COMMAND" 
    21 fi 
+1

İlgili: [Yalnızca geçerli dizin adını bash istemi üzerine (tam yol) göster] (http://superuser.com/q/60555/204979). Kabul edilen cevapta, 'PS1' ayarlaması hakkında bazı iyi bilgiler bulabilirsiniz. – fedorqui

+0

Kabul edilen yanıt, bir '\ W' büyük harfiyle ilgili bir şeyler anlatır. Sorumu bashrc dosyasıyla güncelledim. PS1 zaten \ W olarak ayarlanmış, bu yüzden maalesef bu bana yardımcı olmuyor. Başka öneriler var mı? – sqe

+0

Bu cevapta verilen bağlantılardan geçmeyi düşünün. Ayrıca, sahip olduğunuz mevcut PS1, burada belirtilen tanımla eşleşmiyor. Konfigürasyon dosyalarınızda 'PS1''in daha fazla tanımını yapmak için grep 'diyorum. grep PS1 ~ /.* ' – fedorqui

cevap

14

sizin isteminde kaçış dizisi karşılık gelen bir tamsayı eklemek yolun gösterilen sondaki bileşenlerinin bir dizi belirtmek için. Sizin durumda, %2~ hile yapacaktır. zshmisc alıntı (1):

%d 
%/  Current working directory. If an integer follows the `%', 
     it specifies a number of trailing components of the current 
     working directory to show; zero means the whole path. A 
     negative integer specifies leading components, i.e. %-1d 
     specifies the first component. 

%~  As %d and %/, but if the current working directory starts 
     with $HOME, that part is replaced by a `~'. Furthermore, if 
     it has a named directory as its prefix, that part is replaced 
     by a `~' followed by the name of the directory, but only if 
     the result is shorter than the full path; see Dynamic and 
     Static named directories in zshexpn(1).