firsts scripts

This commit is contained in:
Maciej Krok 2016-09-18 14:20:38 +02:00
commit 1e0c753aaa
13 changed files with 277 additions and 0 deletions

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# mScripts
after cloning repo you can run *bash ./init.sh* then scripts will be accesable to you in bash

8
init.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
echo "" >> ~/.bash_profile
echo "# mScripts added $(date)" >> ~/.bash_profile
echo "export PATH=\$PATH:$(pwd)/scripts" >> ~/.bash_profile
export PATH=$PATH:$(pwd)/scripts
chmod +x $(pwd)/scripts/*

3
scripts/flac2alac Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
for f in ./*.flac; do ffmpeg -i "$f" -c:a alac "${f%.*}.m4a"; done

25
scripts/initdir4 Executable file
View File

@ -0,0 +1,25 @@
#!/bin/bash
if [ -z $1 ];then
echo "usage: initdir4 name [pathToCreata]"
exit
fi
in=.
if [ $2 ];then
in=$2;
fi
mkdir $in/$1
mkdir $in/tmp
mkdir $in/$1/tmp
mkdir $in/$1/documents
mkdir $in/$1/movies
mkdir $in/$1/music
mkdir $in/$1/backup
mkdir $in/$1/pictures

98
scripts/itunes Executable file
View File

@ -0,0 +1,98 @@
#!/bin/sh
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
####################################
showHelp () {
echo "-----------------------------";
echo "iTunes Command Line Interface";
echo "-----------------------------";
echo "Usage: `basename $0` <option>";
echo;
echo "Options:";
echo " status = Shows iTunes' status, current artist and track.";
echo " play = Start playing iTunes.";
echo " pause = Pause iTunes.";
echo " next = Go to the next track.";
echo " prev = Go to the previous track.";
echo " mute = Mute iTunes' volume.";
echo " unmute = Unmute iTunes' volume.";
echo " vol up = Increase iTunes' volume by 10%";
echo " vol down = Increase iTunes' volume by 10%";
echo " vol # = Set iTunes' volume to # [0-100]";
echo " stop = Stop iTunes.";
echo " quit = Quit iTunes.";
}
if [ $# = 0 ]; then
showHelp;
fi
while [ $# -gt 0 ]; do
arg=$1;
case $arg in
"status" ) state=`osascript -e 'tell application "iTunes" to player state as string'`;
echo "iTunes is currently $state.";
if [ $state = "playing" ]; then
artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`;
track=`osascript -e 'tell application "iTunes" to name of current track as string'`;
echo "Current track $artist: $track";
fi
break ;;
"play" ) echo "Playing iTunes.";
osascript -e 'tell application "iTunes" to play';
break ;;
"pause" ) echo "Pausing iTunes.";
osascript -e 'tell application "iTunes" to pause';
break ;;
"next" ) echo "Going to next track." ;
osascript -e 'tell application "iTunes" to next track';
break ;;
"prev" ) echo "Going to previous track.";
osascript -e 'tell application "iTunes" to previous track';
break ;;
"mute" ) echo "Muting iTunes volume level.";
osascript -e 'tell application "iTunes" to set mute to true';
break ;;
"unmute" ) echo "Unmuting iTunes volume level.";
osascript -e 'tell application "iTunes" to set mute to false';
break ;;
"vol" ) echo "Changing iTunes volume level.";
vol=`osascript -e 'tell application "iTunes" to sound volume as integer'`;
if [ $2 = "up" ]; then
newvol=$(( vol+10 ));
fi
if [ $2 = "down" ]; then
newvol=$(( vol-10 ));
fi
if [ $2 -gt 0 ]; then
newvol=$2;
fi
osascript -e "tell application \"iTunes\" to set sound volume to $newvol";
break ;;
"stop" ) echo "Stopping iTunes.";
osascript -e 'tell application "iTunes" to stop';
break ;;
"quit" ) echo "Quitting iTunes.";
osascript -e 'tell application "iTunes" to quit';
exit 1 ;;
"help" | * ) echo "help:";
showHelp;
break ;;
esac
done

42
scripts/macinfo Executable file
View File

@ -0,0 +1,42 @@
echo -----------------------------
echo OS Information Information
echo -----------------------------
sw_vers
echo
echo -----------------------------
echo Airport Interface Information
echo -----------------------------
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I
echo
echo -----------------------------
echo Ping to OpenDNS IP address
echo -----------------------------
ping -c 5 208.67.222.222
echo
echo -----------------------------
echo Ping to google.com by Name
echo -----------------------------
ping -c 5 google.com
echo
echo -----------------------------
echo Public Facing IP Address
echo -----------------------------
wget http://ipinfo.io/ip -qO -
echo
echo
echo -----------------------------
echo Disk Space Information
echo -----------------------------
df -h
echo
echo -----------------------------
echo Folder Size Information
echo -----------------------------
du -sh ~/Documents
du -sh ~/Music
du -sh ~/Pictures
echo
echo -----------------------------
echo System Profile Information
echo -----------------------------
system_profiler

16
scripts/moveivi Executable file
View File

@ -0,0 +1,16 @@
#!/bin/bash
ITUNESLIB=/Volumes/iTunesLibray
IVIDIR=$HOME/Movies/iVI
IVIMOVEDDIR=$HOME/Movies/iVI_moved
#mkdir ${ITUNESLIB}/_tmp/
tree -h ${IVIDIR}
time rsync -vazh --progress --partial ${IVIDIR} ${ITUNESLIB}/_tmp/ \
&& echo "rsync ok" \
&& tree -h ${ITUNESLIB}/_tmp/ \
&& mv ${ITUNESLIB}/_tmp/* ${ITUNESLIB}/Automatically\ Add\ to\ iTunes.localized/ \
&& echo "mv itunes ok" \
&& rsync -vazh --progress --partial ${IVIDIR}/* ${IVIMOVEDDIR}/ \
&& rm -fR ${IVIDIR}/* \
&& echo "mv ivi ok"

28
scripts/mssh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
SSH=/usr/bin/ssh
SSHARGS=""
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
--tmux-name)
TMUXNAME="$2"
HASTMUXNAME=true
shift # past argument
;;
*)
SSHARGS+=" $1"
# unknown option
;;
esac
shift # past argument or value
done
if [[ $HASTMUXNAME ]] ; then
SSHARGS+=" -t \"tmux a -dt $TMUXNAME || tmux new -s $TMUXNAME\""
fi
echo "$SSH" $SSHARGS

3
scripts/pidof Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
ps axc|awk "{if (\$5==\"$1\") print \$1}";

10
scripts/psg Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
#echo $1
if [ $1 ]; then
ps aux | grep $@
else
ps aux
fi

3
scripts/startScreenSaver Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app

31
scripts/startUpItems Executable file
View File

@ -0,0 +1,31 @@
#!/bin/bash
#echo $@
LS="ls -thoral"
DIRS=();
DIRS+=("Login:")
DIRS+=(~/Library/LaunchAgents)
DIRS+=(/Library/LaunchAgents)
DIRS+=(/System/Library/LaunchAgents)
DIRS+=("---------------------------------")
DIRS+=("Boot:")
DIRS+=(/Library/LaunchDaemons)
DIRS+=(/System/Library/LaunchDaemons)
DIRS+=(/Library/StartupItems)
# DIRS+=()
# DIRS+=()
# DIRS+=()
# DIRS+=()
# DIRS+=()
for i in "${!DIRS[@]}"; do
DIR=${DIRS[$i]}
echo $DIR
if [ -d "$DIR" ]; then
if [ $1 ]; then
$LS $DIR | grep $@
else
$LS $DIR
fi
fi
done

7
scripts/whatIsMyIP Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
echo -----------------------------
echo Public Facing IP Address
echo -----------------------------
wget http://ipinfo.io/ip -qO -
echo