From 8164336eacd1aeed3d7df0722ee958ee73f31c04 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Tue, 19 Feb 2019 02:30:42 +0000 Subject: [PATCH] etc/profile.d/mac.sh --- etc/profile.d/mac.sh | 55 +------------------------------------------- etc/profile.d/sys.sh | 7 ++++-- 2 files changed, 6 insertions(+), 56 deletions(-) diff --git a/etc/profile.d/mac.sh b/etc/profile.d/mac.sh index 745ef4fa..3c779bb9 100644 --- a/etc/profile.d/mac.sh +++ b/etc/profile.d/mac.sh @@ -7,29 +7,16 @@ # See: http://www.infoworld.com/article/2614879/mac-os-x/top-20-os-x-command-line-secrets-for-power-users.html # ############################################################################## -mac_pbcopy() { - local host="$1"; shift - cat $@ | ssh -q $host -o 'ForwardAgent yes' 'cat|pbcopy' - -} ############################################################################## # # Darwin only ! case "$OSTYPE" in darwin*) # ############################################################################## -[ -x /opt/local/bin/mysqld_safe5 ] && alias mac_mysqlstart='sudo /opt/local/bin/mysqld_safe5 &' -[ -x /opt/local/bin/mysqladmin5 ] && alias mac_mysqlstop='sudo /opt/local/bin/mysqladmin5 -u root -p shutdown' -[ -x /Applications/iTunes.app/Contents/MacOS/iTunes ] && alias iTunes=/Applications/iTunes.app/Contents/MacOS/iTunes -[ -x /Applications/VLC.app/Contents/MacOS/VLC ] && alias vlc=/Applications/VLC.app/Contents/MacOS/VLC alias strace='dtruss' alias updatedb='sudo sh -c "cd / && exec /usr/libexec/locate.updatedb"' -seq() { - if which seq > /dev/null; then - eval "$(which seq) $@" - return - fi +type -p seq > /dev/null || seq() { if [ -n "$2" ]; then jot - "$1" "$2" else @@ -43,52 +30,12 @@ alias mac_sleep='pmset sleepnow' alias mac_mount_nfs='sudo mount -o resvport -t nfs' alias mac_automount='sudo automount -v' alias mac_dns_flush='sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder' - alias mac_sleep='pmset sleepnow' -alias mac_halt='halt=1 && bash -c "(sleep 3 && halt) &" && logout' - #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 macps_top="echo 'TOP PROCESSES:'; ps -Aro'%cpu, ucomm, user' | grep $USER | grep -v ' 0.0 '" alias mac_mount_nfs="sudo mount -o resvport -t nfs" -if ! which mysql > /dev/null && which mysql5 > /dev/null; then -eval ' -function mysql() { - if ! which mysql > /dev/null && which mysql5 > /dev/null; then - mysql5 $* - else - $(which mysql) $* - fi -} -' -alias mysql=mysql5 -fi - -test "$TERM_PROGRAM" = "iTerm.app" && export PROMPT_COMMAND='printf "\033]0;%s\007" "${USER}@${HOSTNAME%%.*}"' - -free() { - vm_stat | perl -ne '/page size of (\d+)/ and $size=$1; /Pages\s+([^:]+)[^\d]+(\d+)/ and printf("%-23s: %10.2f Mo\n",$1, $2 * $size / 1048576);' -} - -mac_config() { - declare run r; run=" -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 -echo 'Date Format : EEE MMM d H.mm' -defaults write com.apple.menuextra.clock 'DateFormat' 'EEE MMM d H.mm' -killall -KILL SystemUIServer -" - echo "$run" - read -p "Run (y)?: " r - [ "$r" = "y" ] || return 1 - echo "$run" | sudo sh -} - mac_dev_shm() { set -e local usage="Usage: $FUNCNAME [SIZE in MB] [MOUNT DIR (default /dev/shm)]" diff --git a/etc/profile.d/sys.sh b/etc/profile.d/sys.sh index 95d3f405..44741383 100644 --- a/etc/profile.d/sys.sh +++ b/etc/profile.d/sys.sh @@ -139,11 +139,14 @@ sys_os() { } sys_mem_total() { - sysctl -n hw.memsize 2>/dev/null || free -b | awk '/^Mem:/{print $2; exit}' + sysctl -n hw.memsize 2>/dev/null && return + free -b | awk '/^Mem:/{print $2; exit}' && return } sys_mem_used() { - sysctl -n hw.usermem 2>/dev/null || free -b | awk '/^Mem:/{print $3; exit}' + ps -caxm -orss= | awk '{ sum += $1 } END { print sum*1000 }' && return + free -b | awk '/^Mem:/{print $3; exit}' && return + #sysctl -n hw.usermem 2>/dev/null && return } #sys_mem_free() { echo $((`sys_mem_total` - `sys_mem_used`)); } -- 2.47.3