Skip to content

Commit 6fd6c21

Browse files
committed
Adding initial scripts
0 parents  commit 6fd6c21

37 files changed

+1528
-0
lines changed

backup.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
echo "Back-up Files"
4+
5+
exit 0

bash-aliases-abbreviated.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# aliases
2+
alias g=git
3+
alias gk='gitk &'
4+
alias gka='gitk --all &'
5+
alias gd='git diff'
6+
alias gdc='git diff --cached'
7+
if [[ "$OSTYPE" == 'linux-gnu' ]]; then
8+
alias s=./symfony
9+
alias symfony=./symfony
10+
else
11+
alias s=symfony
12+
fi

byzanz-record-region.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
3+
# Delay before starting
4+
DELAY=1
5+
6+
# Sound notification to let one know when recording is about to start (and ends)
7+
beep() {
8+
paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg &
9+
}
10+
11+
# Duration and output file
12+
if [ $# -gt 0 ]; then
13+
D="--duration=$@"
14+
else
15+
echo Default recording duration 10s to /tmp/recorded.gif
16+
D="--duration=10 /tmp/recorded.gif"
17+
fi
18+
19+
# xrectsel from https://github.com/lolilolicon/xrectsel
20+
ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1
21+
22+
echo Delaying $DELAY seconds. After that, byzanz will start
23+
for (( i=$DELAY; i>0; --i )) ; do
24+
echo $i
25+
sleep 1
26+
done
27+
#beep
28+
byzanz-record --verbose --delay=0 ${ARGUMENTS} $D
29+
#beep

byzanz-screencapture-monitor1.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# @author Ryan McIntyre
3+
# references:
4+
# http://stackoverflow.com/questions/2642585/read-a-variable-in-bash-with-a-default-value
5+
6+
# default to 10
7+
read -p "Duration of seconds to run (enter for default of 10): " DURATION
8+
DURATION=${DURATION:-10}
9+
echo $DURATION
10+
11+
# default to 0
12+
read -p "X position (enter for default of 0): " XPOS
13+
XPOS=${XPOS:-0}
14+
echo $XPOS
15+
16+
# default to 0
17+
read -p "Y position (enter for default of 0): " YPOS
18+
YPOS=${YPOS:-0}
19+
echo $YPOS
20+
21+
# default to 1920
22+
read -p "Width (enter for default of 1920): " WIDTH
23+
WIDTH=${WIDTH:-1920}
24+
echo $WIDTH
25+
26+
# default to 1
27+
read -p "Delay (enter for default of 1): " DELAY
28+
DELAY=${DELAY:-1}
29+
echo $DELAY
30+
31+
OUTDIR=~/Screencasts/byzanz
32+
# e.g. 29-Apr-2014-07:31:31 PM
33+
DATE=$(date +"%d-%b-%Y-%r")
34+
35+
# check if directory doesn't exist and not linked file
36+
if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then
37+
mkdir -p $OUTDIR
38+
fi
39+
40+
byzanz-record --duration=$DURATION --x=$XPOS --y=$YPOS --width=$WIDTH --delay=$DELAY "$OUTDIR/screencast_$DATE.gif"
41+
42+
thunar $OUTDIR

byzanz-screencapture-monitor2.sh

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# @author Ryan McIntyre
3+
# references:
4+
# http://stackoverflow.com/questions/2642585/read-a-variable-in-bash-with-a-default-value
5+
6+
# default to 10
7+
read -p "Duration of seconds to run (enter for default of 10): " DURATION
8+
DURATION=${DURATION:-10}
9+
echo $DURATION
10+
11+
# default to 1920
12+
read -p "X position (enter for default of 1920): " XPOS
13+
XPOS=${XPOS:-1920}
14+
echo $XPOS
15+
16+
# default to 0
17+
read -p "Y position (enter for default of 0): " YPOS
18+
YPOS=${YPOS:-0}
19+
echo $YPOS
20+
21+
# default to 1920
22+
read -p "Width (enter for default of 1920): " WIDTH
23+
WIDTH=${WIDTH:-1920}
24+
echo $WIDTH
25+
26+
# default to 1
27+
read -p "Delay (enter for default of 1): " DELAY
28+
DELAY=${DELAY:-1}
29+
echo $DELAY
30+
31+
OUTDIR=~/Screencasts/byzanz
32+
# e.g. 29-Apr-2014-07:31:31 PM
33+
DATE=$(date +"%d-%b-%Y-%r")
34+
35+
# check if directory doesn't exist and not linked file
36+
if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then
37+
mkdir -p $OUTDIR
38+
fi
39+
40+
byzanz-record --duration=$DURATION --x=$XPOS --y=$YPOS --width=$WIDTH --delay=$DELAY "$OUTDIR/screencast_$DATE.gif"
41+
42+
thunar $OUTDIR

byzanz-screencapture-via-xrectsel.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
# @author Ryan McIntyre
3+
# references:
4+
# http://stackoverflow.com/questions/2642585/read-a-variable-in-bash-with-a-default-value
5+
# http://choorucode.com/2014/01/24/how-to-screen-capture-a-region-to-gif-using-byzanz/
6+
7+
# default to 10
8+
read -p "Duration of seconds to run (enter for default of 10): " DURATION
9+
DURATION=${DURATION:-10}
10+
echo $DURATION
11+
12+
# default to 1
13+
read -p "Delay (enter for default of 1): " DELAY
14+
DELAY=${DELAY:-1}
15+
echo $DELAY
16+
17+
OUTDIR=~/Screencasts/byzanz
18+
# e.g. 29-Apr-2014-07:31:31 PM
19+
DATE=$(date +"%d-%b-%Y-%r")
20+
21+
# check if directory doesn't exist and not linked file
22+
if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then
23+
mkdir -p $OUTDIR
24+
fi
25+
26+
# xrectsel from https://github.com/lolilolicon/xrectsel
27+
ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1
28+
29+
byzanz-record --verbose --delay=$DELAY ${ARGUMENTS} --duration=$DURATION "$OUTDIR/screencast_$DATE.gif"
30+
31+
thunar $OUTDIR
32+
33+
34+
35+

custom-bash-prompt-git-railsdog.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# original source:
2+
# http://railsdog.com/blog/2009/03/07/custom-bash-prompt-for-git-branches/
3+
4+
function parse_git_dirty {
5+
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
6+
}
7+
8+
function parse_git_branch {
9+
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
10+
}
11+
12+
export PS1='\W$(__git_ps1 "[\[\e[0;32m\]%s\[\e[0m\]\[\e[0;33m\]$(parse_git_dirty)\[\e[0m\]]")$ '

dd-backup.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
# backup partitions using dd
3+
4+
echo "Back-up Files"
5+
6+
# variables
7+
DATE=$(date +"%Y-%m-%d")
8+
BACKUP_DIR_PARENT="/mnt/nas/msi-gp60-laptop"
9+
DESTINATION_DIR=$BACKUP_DIR_PARENT/$DATE
10+
# keep track of how long script takes to run
11+
bench_start=$SECONDS
12+
# store current path of script (help with relative paths)
13+
MY_DIR=`dirname $0`
14+
15+
if [ -e $MY_DIR/unix-color-codes-not-escaped.sh ]; then
16+
echo -e "${On_Green}Unix color code file found, including.. ${Color_Off}"
17+
$MY_DIR/unix-color-codes-not-escaped.sh
18+
else
19+
echo -e "${On_Red}Unix color code file not found${Color_Off}"
20+
fi
21+
22+
# check if directory doesn't exist and not linked file
23+
if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then
24+
echo -e "${On_Blue}Directory not found, probably first time running. creating: $DESTINATION_DIR${Color_Off}"
25+
# Control will enter here if $DIR doesn't exist.
26+
mkdir -p $DESTINATION_DIR
27+
# compare exit stats/code of last cmd
28+
if [ "$?" -ne "0" ]; then
29+
echo -e "${On_Red}Sorry, could not create the directory: ${DESTINATION_DIR} ${Color_Off}"
30+
exit 1
31+
fi
32+
fi
33+
34+
# home backup
35+
sudo dd if=/dev/sda7 | gzip -9 > $DESTINATION_DIR/sda7_home.img.gz
36+
# filesystem root
37+
sudo dd if=/dev/sda8 | gzip -9 > $DESTINATION_DIR/sda8_filesystem.img.gz
38+
39+
bench_end=$SECONDS
40+
41+
total_time=$(expr $bench_end - $bench_start)
42+
43+
echo "Backup finished successfully [total time in seconds: $total_time]"
44+
#exit 0

dropbox-thunar-hack.sh

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
exec thunar ~/Dropbox
3+
exit 0
4+
# sources:
5+
# http://unix.stackexchange.com/questions/34045/how-can-i-change-which-file-manager-dropbox-opens-with-by-default

find-class-files.sh

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
# @author Ryan McIntyre
3+
4+
# e.g. 1
5+
cat lib/model/doctrine/base/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*'
6+
7+
# e.g. 2
8+
cat lib/model/doctrine/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*'
9+
10+
# e.g. 3
11+
cat lib/form/doctrine/base/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*'
12+
13+
14+
# e.g. latest
15+
cat lib/form/doctrine/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*'

find-duplicate-files.sh

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
#
3+
4+
find -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate

find-files-not-owned-by-user-group.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
# Find/list files not owned by user and group given
3+
USER=ryan
4+
GROUP=ryan
5+
6+
sudo find . ! -user $USER -o ! -group $GROUP | more

git-bash-ps1-examples.txt

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
2+
# source
3+
# https://makandracards.com/makandra/1090-customize-your-bash-prompt
4+
5+
export PS1='\h \w$(__git_ps1 "(%s)") \$ '
6+
=> mycomputer ~/apps/chess/tmp(master) $ _
7+
8+
export PS1='\[\e[33m\]\h\[\e[0m\]:\W\[\e[33m\]$(__git_ps1 "(%s)")\[\e[0m\] \u\$ '
9+
=> mycomputer:tmp(master) tom$ _
10+
11+
# Henning's awesome TRON prompt 2.0.2 with current Git branch and success state of the last command (the syntax coloring here does not do it justice):
12+
export PS1='`if [ $? = 0 ]; then echo "\[\033[01;32m\]✔"; else echo "\[\033[01;31m\]✘"; fi` \[\033[01;30m\]\h\[\033[01;34m\] \w\[\033[35m\]$(__git_ps1 " %s") \[\033[01;30m\]>\[\033[00m\] '
13+
=> ✔ mycomputer ~/projects/platforms master > _
14+
15+
# Arne's epic timestamped prompt with return status indicator and status-colored (green or red, if unstaged) git branch:
16+
export PS1='\[\e[01;30m\]\t `if [ $? = 0 ]; then echo "\[\e[32m\]"; else echo "\[\e[31m\]✘"; fi` \[\e[00;37m\]\u\[\e[01;37m\]:`[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "\[\e[31m\]" || echo "\[\e[32m\]"`$(__git_ps1 "(%s)\[\e[00m\]")\[\e[01;34m\]\w\[\e[00m\]\$ '
17+
=> 03:13:37 ✔ arne:(master)~/projects/geordi$ _
18+
19+
# Arne's danger prompt for root use. No git information and alarming red and yellow (which you can't see here):
20+
export PS1='\[\e[01;30m\]\t \[\e[31m\]\u\[\e[37m\]:\[\e[33m\]\w\[\e[31m\]\$\[\033[00m\] '
21+
=> 03:13:37 root:/tmp/foo# _
22+
23+
# Kim's mix of those above with small changes. TRON promt with timestamp, return status indicator, hostname, git informations and working directory (but all non-bold).
24+
export PS1='\[\033[01;30m\]\t `if [ $? = 0 ]; then echo "\[\033[01;32m\]ツ"; else echo "\[\033[01;31m\]✗"; fi` \[\033[00;32m\]\h\[\033[00;37m\]:\[\033[31m\]$(__git_ps1 "(%s)\[\033[01m\]")\[\033[00;34m\]\w\[\033[00m\] >'
25+
=> 03:13:37 ツ mycomputer:(master)~/code/foo >
26+
27+
# Kim's root promt (the same as above without git and the hostname is red)
28+
export PS1='\[\033[01;30m\]\t `if [ $? = 0 ]; then echo "\[\033[01;32m\]ツ"; else echo "\[\033[01;31m\]✗"; fi` \[\033[00;31m\]\h\[\033[00;37m\]:\[\033[00;34m\]\w\[\033[00m\] >'
29+
=> 03:13:37 ツ mycomputer:~/code/foo >

git-diff-wrapper.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/sh
2+
3+
# diff is called by git with 7 parameters:
4+
# path old-file old-hex old-mode new-file new-hex new-mode
5+
"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" "$2" "$5" | cat
6+
7+
#"C:/Program Files/WinMerge/WinMergeU.exe" "$2" "$5" | cat
8+
#"C:/Program Files/KDiff3/kdiff3.exe" "$2" "$5" | cat

git-hook-console-log.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
# git diff --cached = stagged changes
4+
# git diff = all changes
5+
6+
has_console_log=$(git diff --cached | grep -F 'console.log')
7+
8+
if [ "$has_console_log" != "" ]
9+
then
10+
echo "ERROR: You have console.log in your changes. Consider removing them."
11+
exit 1
12+
fi
13+
14+
has_console_log=$(git diff | grep -F 'console.log')
15+
16+
if [ "$has_console_log" != "" ]
17+
then
18+
echo "ERROR: You have console.log in your changes. Consider removing them."
19+
exit 1
20+
fi

git-hook-trailing-whitespace.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
# source: http://css.dzone.com/articles/all-git-hooks-you-need
3+
# Force remove trailing-whitespaces (and carriage-return in linux)
4+
5+
if git rev-parse --verify HEAD >/dev/null 2>&1
6+
then
7+
against=HEAD
8+
else
9+
# Initial commit: diff against an empty tree object
10+
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
11+
fi
12+
13+
# Find files with trailing whitespace
14+
for FILE in `exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | cut -f1 -d: | uniq` ; do
15+
# Fix them!
16+
sed -i 's/\s\+$//' "$FILE"
17+
git add "$FILE"
18+
done
19+
20+
exit

git-merge-diffmerge-wrapper.sh

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# Passing the following parameters to mergetool:
4+
# local base remote merge_result
5+
6+
# params should come as: "$PWD/$LOCAL" "$PWD/$BASE" "$PWD/$REMOTE" "$PWD/$MERGED"
7+
#"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" "$1" "$2" "$3" --result="$4" --title1="Mine" --title2="Merging to: $4" --title3="Theirs"
8+
#"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" "$1" "$2" "$3" --result="$4" --title1="Mine (LOCAL - Current branch verion (probably master?))" --title2="Merging to: $4" --title3="Theirs (REMOTE - Version to be merged (probably a topic branch?))"
9+
diffmerge "$1" "$2" "$3" --result="$4" --title1="Mine (LOCAL - Current branch verion (probably master?))" --title2="Merging to: $4" --title3="Theirs (REMOTE - Version to be merged (probably a topic branch?))"

0 commit comments

Comments
 (0)