0

On the server I connnect to my home path is like this:/home/junk1/junk2/user. I can use the sed command pwd | sed -e 's|^/\([[:alnum:]]*\)/[[:alpha:]]*/[[:alpha:]]*|/\1|' to shorten the directory path to this: /home/user.

On the tmux status bar I can set the current directory with set -g status-right '#(pwd)'. However, because i want to shorten the paths, I tried the above expression by setting:

set -g status-right "#(pwd | sed -e 's|^/ ([[:alnum:]]*\)/[[:alpha:]]*/[[:alpha:]]*|/\1|')"

This doesn't work. The status bar gets updated with some portion of the text from the sed expression. How can I fix this?

  • OFF: sed 's|\>\(/[^/]*\)\{2\}||' looks better – Costas Apr 26 '15 at 20:54
  • Are you sure to exchange quotes ' / " ? Where is missed \ before ( in s|^/ ([[:alnum – Costas Apr 26 '15 at 20:59
  • @Costas I missed the \ in the expression while typing here. But the slash is present in my codes. I don't understand your question about the quotes. – deepak Apr 26 '15 at 21:07
  • In your sample set -g status-right '#(pwd)' but you use ". A you sure that isnot a trouble reason? – Costas Apr 27 '15 at 16:32
  • If i replace all double quotes by single quotes then nothing gets displayed. If I switch the double and single quotes in the expression, then the entire thing /home/junk1/junk2/user is displayed and this doesn't change when changing directories. – deepak Apr 28 '15 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.