Only replace username when preceded by a space

This commit is contained in:
Nathan Broadbent
2012-10-15 21:57:24 +13:00
parent 57d42b983d
commit 1d3651904b

View File

@@ -96,7 +96,7 @@ if [ -e $HOME/.user_sym ]; then
function rejustify_ls_columns(){
ruby -e "o=STDIN.read;re=/^(([^ ]* +){2})(([^ ]* +){3})/;u,g,s=o.lines.map{|l|l[re,3]}.compact.map(&:split).transpose.map{|a|a.map(&:size).max+1};puts o.lines.map{|l|l.sub(re){|m|\"%s%-#{u}s %-#{g}s%#{s}s \"%[\$1,*\$3.split]}}"
}
_ls_processor="| sed \"s/$USER/\$(/bin/cat $HOME/.user_sym)/g\" | rejustify_ls_columns"
_ls_processor="| sed \"s/ $USER/ \$(/bin/cat $HOME/.user_sym)/g\" | rejustify_ls_columns"
fi