Permalink
Browse files

Rejustify columns for ls after user sym is substituted

  • Loading branch information...
1 parent f099bd5 commit cc7510eceec5707ba21e10c25c8794f760f05bf7 @ndbroadbent committed Oct 14, 2012
Showing with 9 additions and 7 deletions.
  1. +4 −6 bashrc/aliases.sh
  2. +5 −1 bashrc/functions.sh
View
@@ -6,14 +6,12 @@
# Before : -rw-rw-r-- 1 ndbroadbent ndbroadbent 1.1K Sep 19 21:39 scm_breeze.sh
# After : -rw-rw-r-- 1 𝐍 𝐍 1.1K Sep 19 21:39 scm_breeze.sh
if [ -e $HOME/.user_sym ]; then
- _sub_user_sym=" | sed \"s/$USER/\$(/bin/cat $HOME/.user_sym)/g\""
+ _ll_processor=" | sed \"s/$USER/\$(/bin/cat $HOME/.user_sym)/g\" | rejustify_ls_columns"
fi
-alias l="ls -Cv --group-directories-first $_sub_user_sym"
-alias ll="ls -lhv --group-directories-first $_sub_user_sym"
-alias la="ls -lhvA --group-directories-first $_sub_user_sym"
-
-
+alias l="ls -Cv --group-directories-first"
+alias ll="ls -lhv --group-directories-first $_ls_processor"
+alias la="ls -lhvA --group-directories-first $_ls_processor"
alias rmrf='rm -rf'
alias ldu='du -cks * | sort -rn | head -15' # Lists the size of all the folders
View
@@ -24,7 +24,7 @@ total_replace() {
local capitalized=$(printf $search | sed 's/[^ _-]*/\L\u&/g')
search="$lowercased $capitalized"
fi
- if [ "$3" = "-c" ]; then
+ if [ "$3" = "-c" ]; then
# Set default path if path option skipped
local path="."
else
@@ -59,6 +59,10 @@ fix_whitespace() {
find . -not -path '.git' -iname '*.rb' -print0 | xargs -0 sed -i -e 's/[[:space:]]*$//g' -e '${/^$/!s/$/\n/;}'
}
+# Rejustify the user/group/size columns after username/group is replaced with symbols
+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]}}"
+}
# Look busy
random_hex() { for i in $(seq 1 2); do echo -n $(echo "obase=16; $(($RANDOM % 16))" | bc | tr '[A-Z]' '[a-z]'); done; }

0 comments on commit cc7510e

Please sign in to comment.