]> git.nbdom.net Git - nb.git/commitdiff
bin + etc
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 17 Nov 2014 21:17:04 +0000 (22:17 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 17 Nov 2014 21:17:04 +0000 (22:17 +0100)
etc/bashrc

index 02418d10ff55cd38f1ace14596ecaea0ed228516..b2c6c515fdcb1a92b04f6f6bdf098bdd3bd9f245 100644 (file)
@@ -222,36 +222,35 @@ alias servers-upgrade='server-package.pl update,upgrade $(printf "localhost\nbig
 # Mac OS
 #
 
-case "$OSTYPE" in
-darwin*) 
-
-alias strace='dtruss'
-alias updatedb='bash -c "cd / && /usr/libexec/locate.updatedb &"'
-alias mac-dns-flush='dscacheutil -flushcache'
-#alias mac-wakeup-screen="pmset schedule wake '\$(date +\"%d/%m/%Y %T\")'"
-#alias mac-wakeup-screen2='osascript -e \'tell application "System Events" to key code 123\''
-alias mac-sleep='pmset sleepnow'
-alias mac-halt='halt=1 && bash -c "(sleep 3 && halt) &" && logout'
-alias mac-top-proc="echo 'TOP PROCESSES:'; ps -Aro'%cpu, ucomm, user' | grep $USER | grep -v ' 0.0 '"
-alias mac-automount='sudo automount -v'
-alias mac-vlc-playlists="open -a vlc --args /home/nico/Music/*/*.m3u"
-# NB 25.02.14 alias hibernate='sudo pmset -a hibernatemode 25'
-# NB 25.02.14 alias sleep='sudo pmset -a hibernatemode 0'
-# NB 25.02.14 alias safesleep='sudo pmset -a hibernatemode 3'
-# NB 25.02.14 alias smartsleep='sudo pmset -a hibernatemode 2'
-mac_xmessagei() {
-  osascript -e 'tell app "System Events" to display dialog "'$@'"'
-}
+case "$OSTYPE" in darwin*) 
+
+  alias strace='dtruss'
+  alias updatedb='bash -c "cd / && /usr/libexec/locate.updatedb &"'
+  alias mac-dns-flush='dscacheutil -flushcache'
+  #alias mac-wakeup-screen="pmset schedule wake '\$(date +\"%d/%m/%Y %T\")'"
+  #alias mac-wakeup-screen2='osascript -e \'tell application "System Events" to key code 123\''
+  alias mac-sleep='pmset sleepnow'
+  alias mac-halt='halt=1 && bash -c "(sleep 3 && halt) &" && logout'
+  alias mac-top-proc="echo 'TOP PROCESSES:'; ps -Aro'%cpu, ucomm, user' | grep $USER | grep -v ' 0.0 '"
+  alias mac-automount='sudo automount -v'
+  alias mac-vlc-playlists="open -a vlc --args /home/nico/Music/*/*.m3u"
+  # NB 25.02.14 alias hibernate='sudo pmset -a hibernatemode 25'
+  # NB 25.02.14 alias sleep='sudo pmset -a hibernatemode 0'
+  # NB 25.02.14 alias safesleep='sudo pmset -a hibernatemode 3'
+  # NB 25.02.14 alias smartsleep='sudo pmset -a hibernatemode 2'
+  mac-xmessage() {
+    osascript -e 'tell app "System Events" to display dialog "'$@'"'
+  }
+
+  mac_config() {
+    echo "Finder path           : YES"
+    defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
+    echo "Finder quit           : YES"
+    defaults write com.apple.finder QuitMenuItem -bool YES
+    echo "Finder show all files : FALSE"
+    defaults write com.apple.finder AppleShowAllFiles FALSE
+  }
 
-mac_config() {
-       echo "Finder path           : YES"
-       defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES
-       echo "Finder quit           : YES"
-       defaults write com.apple.finder QuitMenuItem -bool YES
-       echo "Finder show all files : FALSE"
-       defaults write com.apple.finder AppleShowAllFiles FALSE
-}
-;;
 esac
 
 #################################################################################
@@ -289,3 +288,34 @@ unzipurl() {
    wget "$url" -O "$file" && unzip "$file"
    rm "$file"
 }
+
+bytes2h() {
+  declare in="cat" args=""
+  if [ "$1" == "-regex" ]; then
+    args="regex=$2"
+    shift
+    shift
+  fi
+  [ -z "$@" ] || in="echo $@"
+  $in | perl -pe 'BEGIN{
+  $exp = "([\\d\\.]+)";
+  if (@ARGV and $ARGV[0] =~ /regex=(\S+)/) {
+    shift @ARGV;
+    $exp = $1;
+  }
+  sub oct2h {
+
+  my $o = shift @_;
+  $o = $o * 1024;
+
+  if ($o >= 1099511627776) { return(sprintf("%.2fT",($o/1099511627776))); } # T
+  elsif ($o >= 1073741824) { return(sprintf("%.2fG",($o/1073741824))); } # G
+  elsif ($o >= 1048576) { return(int($o/1048576)."M"); } # M
+  elsif ($o >= 1024) { return(int($o/1024)."K"); } # K
+  else { return $o."bytes"; }
+
+  }
+};
+s/$exp/oct2h($1)/ge;
+' $args
+}