diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..58e6197 --- /dev/null +++ b/backup.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +echo "Back-up Files" + +exit 0 diff --git a/bash-aliases-abbreviated.sh b/bash-aliases-abbreviated.sh new file mode 100755 index 0000000..20ec21e --- /dev/null +++ b/bash-aliases-abbreviated.sh @@ -0,0 +1,12 @@ +# aliases +alias g=git +alias gk='gitk &' +alias gka='gitk --all &' +alias gd='git diff' +alias gdc='git diff --cached' +if [[ "$OSTYPE" == 'linux-gnu' ]]; then + alias s=./symfony + alias symfony=./symfony +else + alias s=symfony +fi diff --git a/byzanz-record-region.sh b/byzanz-record-region.sh new file mode 100755 index 0000000..04aa70e --- /dev/null +++ b/byzanz-record-region.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Delay before starting +DELAY=1 + +# Sound notification to let one know when recording is about to start (and ends) +beep() { + paplay /usr/share/sounds/KDE-Im-Irc-Event.ogg & +} + +# Duration and output file +if [ $# -gt 0 ]; then + D="--duration=$@" +else + echo Default recording duration 10s to /tmp/recorded.gif + D="--duration=10 /tmp/recorded.gif" +fi + +# xrectsel from https://github.com/lolilolicon/xrectsel +ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1 + +echo Delaying $DELAY seconds. After that, byzanz will start +for (( i=$DELAY; i>0; --i )) ; do + echo $i + sleep 1 +done +#beep +byzanz-record --verbose --delay=0 ${ARGUMENTS} $D +#beep diff --git a/byzanz-screencapture-monitor1.sh b/byzanz-screencapture-monitor1.sh new file mode 100755 index 0000000..9b3b61b --- /dev/null +++ b/byzanz-screencapture-monitor1.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# @author Ryan McIntyre +# references: +# http://stackoverflow.com/questions/2642585/read-a-variable-in-bash-with-a-default-value + +# default to 10 +read -p "Duration of seconds to run (enter for default of 10): " DURATION +DURATION=${DURATION:-10} +echo $DURATION + +# default to 0 +read -p "X position (enter for default of 0): " XPOS +XPOS=${XPOS:-0} +echo $XPOS + +# default to 0 +read -p "Y position (enter for default of 0): " YPOS +YPOS=${YPOS:-0} +echo $YPOS + +# default to 1920 +read -p "Width (enter for default of 1920): " WIDTH +WIDTH=${WIDTH:-1920} +echo $WIDTH + +# default to 1 +read -p "Delay (enter for default of 1): " DELAY +DELAY=${DELAY:-1} +echo $DELAY + +OUTDIR=~/Screencasts/byzanz +# e.g. 29-Apr-2014-07:31:31 PM +DATE=$(date +"%d-%b-%Y-%r") + +# check if directory doesn't exist and not linked file +if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then + mkdir -p $OUTDIR +fi + +byzanz-record --duration=$DURATION --x=$XPOS --y=$YPOS --width=$WIDTH --delay=$DELAY "$OUTDIR/screencast_$DATE.gif" + +thunar $OUTDIR diff --git a/byzanz-screencapture-monitor2.sh b/byzanz-screencapture-monitor2.sh new file mode 100755 index 0000000..538ec06 --- /dev/null +++ b/byzanz-screencapture-monitor2.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# @author Ryan McIntyre +# references: +# http://stackoverflow.com/questions/2642585/read-a-variable-in-bash-with-a-default-value + +# default to 10 +read -p "Duration of seconds to run (enter for default of 10): " DURATION +DURATION=${DURATION:-10} +echo $DURATION + +# default to 1920 +read -p "X position (enter for default of 1920): " XPOS +XPOS=${XPOS:-1920} +echo $XPOS + +# default to 0 +read -p "Y position (enter for default of 0): " YPOS +YPOS=${YPOS:-0} +echo $YPOS + +# default to 1920 +read -p "Width (enter for default of 1920): " WIDTH +WIDTH=${WIDTH:-1920} +echo $WIDTH + +# default to 1 +read -p "Delay (enter for default of 1): " DELAY +DELAY=${DELAY:-1} +echo $DELAY + +OUTDIR=~/Screencasts/byzanz +# e.g. 29-Apr-2014-07:31:31 PM +DATE=$(date +"%d-%b-%Y-%r") + +# check if directory doesn't exist and not linked file +if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then + mkdir -p $OUTDIR +fi + +byzanz-record --duration=$DURATION --x=$XPOS --y=$YPOS --width=$WIDTH --delay=$DELAY "$OUTDIR/screencast_$DATE.gif" + +thunar $OUTDIR diff --git a/byzanz-screencapture-via-xrectsel.sh b/byzanz-screencapture-via-xrectsel.sh new file mode 100755 index 0000000..b95fa95 --- /dev/null +++ b/byzanz-screencapture-via-xrectsel.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# @author Ryan McIntyre +# references: +# http://stackoverflow.com/questions/2642585/read-a-variable-in-bash-with-a-default-value +# http://choorucode.com/2014/01/24/how-to-screen-capture-a-region-to-gif-using-byzanz/ + +# default to 10 +read -p "Duration of seconds to run (enter for default of 10): " DURATION +DURATION=${DURATION:-10} +echo $DURATION + +# default to 1 +read -p "Delay (enter for default of 1): " DELAY +DELAY=${DELAY:-1} +echo $DELAY + +OUTDIR=~/Screencasts/byzanz +# e.g. 29-Apr-2014-07:31:31 PM +DATE=$(date +"%d-%b-%Y-%r") + +# check if directory doesn't exist and not linked file +if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then + mkdir -p $OUTDIR +fi + +# xrectsel from https://github.com/lolilolicon/xrectsel +ARGUMENTS=$(xrectsel "--x=%x --y=%y --width=%w --height=%h") || exit -1 + +byzanz-record --verbose --delay=$DELAY ${ARGUMENTS} --duration=$DURATION "$OUTDIR/screencast_$DATE.gif" + +thunar $OUTDIR + + + + diff --git a/custom-bash-prompt-git-railsdog.sh b/custom-bash-prompt-git-railsdog.sh new file mode 100755 index 0000000..83ee395 --- /dev/null +++ b/custom-bash-prompt-git-railsdog.sh @@ -0,0 +1,12 @@ +# original source: +# http://railsdog.com/blog/2009/03/07/custom-bash-prompt-for-git-branches/ + +function parse_git_dirty { + [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" +} + +function parse_git_branch { + git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" +} + +export PS1='\W$(__git_ps1 "[\[\e[0;32m\]%s\[\e[0m\]\[\e[0;33m\]$(parse_git_dirty)\[\e[0m\]]")$ ' \ No newline at end of file diff --git a/dd-backup.sh b/dd-backup.sh new file mode 100755 index 0000000..41f5905 --- /dev/null +++ b/dd-backup.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# backup partitions using dd + +echo "Back-up Files" + +# variables +DATE=$(date +"%Y-%m-%d") +BACKUP_DIR_PARENT="/mnt/nas/msi-gp60-laptop" +DESTINATION_DIR=$BACKUP_DIR_PARENT/$DATE +# keep track of how long script takes to run +bench_start=$SECONDS +# store current path of script (help with relative paths) +MY_DIR=`dirname $0` + +if [ -e $MY_DIR/unix-color-codes-not-escaped.sh ]; then + echo -e "${On_Green}Unix color code file found, including.. ${Color_Off}" + $MY_DIR/unix-color-codes-not-escaped.sh +else + echo -e "${On_Red}Unix color code file not found${Color_Off}" +fi + +# check if directory doesn't exist and not linked file +if [[ ! -d "${DESTINATION_DIR}" && ! -L "${DESTINATION_DIR}" ]] ; then + echo -e "${On_Blue}Directory not found, probably first time running. creating: $DESTINATION_DIR${Color_Off}" + # Control will enter here if $DIR doesn't exist. + mkdir -p $DESTINATION_DIR + # compare exit stats/code of last cmd + if [ "$?" -ne "0" ]; then + echo -e "${On_Red}Sorry, could not create the directory: ${DESTINATION_DIR} ${Color_Off}" + exit 1 + fi +fi + +# home backup +sudo dd if=/dev/sda7 | gzip -9 > $DESTINATION_DIR/sda7_home.img.gz +# filesystem root +sudo dd if=/dev/sda8 | gzip -9 > $DESTINATION_DIR/sda8_filesystem.img.gz + +bench_end=$SECONDS + +total_time=$(expr $bench_end - $bench_start) + +echo "Backup finished successfully [total time in seconds: $total_time]" +#exit 0 diff --git a/dropbox-thunar-hack.sh b/dropbox-thunar-hack.sh new file mode 100644 index 0000000..c61ffa6 --- /dev/null +++ b/dropbox-thunar-hack.sh @@ -0,0 +1,5 @@ +#!/bin/bash +exec thunar ~/Dropbox +exit 0 +# sources: +# http://unix.stackexchange.com/questions/34045/how-can-i-change-which-file-manager-dropbox-opens-with-by-default diff --git a/find-class-files.sh b/find-class-files.sh new file mode 100755 index 0000000..1837970 --- /dev/null +++ b/find-class-files.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# @author Ryan McIntyre + +# e.g. 1 +cat lib/model/doctrine/base/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*' + +# e.g. 2 +cat lib/model/doctrine/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*' + +# e.g. 3 +cat lib/form/doctrine/base/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*' + + +# e.g. latest +cat lib/form/doctrine/*.class.php | sed 's|\r$||' | sort | uniq --all-repeated | uniq --count | grep "class " | grep -v '*' \ No newline at end of file diff --git a/find-duplicate-files.sh b/find-duplicate-files.sh new file mode 100644 index 0000000..3bc8d21 --- /dev/null +++ b/find-duplicate-files.sh @@ -0,0 +1,4 @@ +#!/bin/sh +# + +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 diff --git a/find-files-not-owned-by-user-group.sh b/find-files-not-owned-by-user-group.sh new file mode 100644 index 0000000..1d97d27 --- /dev/null +++ b/find-files-not-owned-by-user-group.sh @@ -0,0 +1,6 @@ +#!/bin/sh +# Find/list files not owned by user and group given +USER=ryan +GROUP=ryan + +sudo find . ! -user $USER -o ! -group $GROUP | more diff --git a/git-bash-ps1-examples.txt b/git-bash-ps1-examples.txt new file mode 100644 index 0000000..671c1bc --- /dev/null +++ b/git-bash-ps1-examples.txt @@ -0,0 +1,29 @@ + +# source +# https://makandracards.com/makandra/1090-customize-your-bash-prompt + +export PS1='\h \w$(__git_ps1 "(%s)") \$ ' +=> mycomputer ~/apps/chess/tmp(master) $ _ + +export PS1='\[\e[33m\]\h\[\e[0m\]:\W\[\e[33m\]$(__git_ps1 "(%s)")\[\e[0m\] \u\$ ' +=> mycomputer:tmp(master) tom$ _ + +# 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): +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\] ' +=> ✔ mycomputer ~/projects/platforms master > _ + +# Arne's epic timestamped prompt with return status indicator and status-colored (green or red, if unstaged) git branch: +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\]\$ ' +=> 03:13:37 ✔ arne:(master)~/projects/geordi$ _ + +# Arne's danger prompt for root use. No git information and alarming red and yellow (which you can't see here): +export PS1='\[\e[01;30m\]\t \[\e[31m\]\u\[\e[37m\]:\[\e[33m\]\w\[\e[31m\]\$\[\033[00m\] ' +=> 03:13:37 root:/tmp/foo# _ + +# 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). +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\] >' +=> 03:13:37 ツ mycomputer:(master)~/code/foo > + +# Kim's root promt (the same as above without git and the hostname is red) +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\] >' +=> 03:13:37 ツ mycomputer:~/code/foo > \ No newline at end of file diff --git a/git-diff-wrapper.sh b/git-diff-wrapper.sh new file mode 100644 index 0000000..bb2ebf7 --- /dev/null +++ b/git-diff-wrapper.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +# diff is called by git with 7 parameters: +# path old-file old-hex old-mode new-file new-hex new-mode +"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" "$2" "$5" | cat + +#"C:/Program Files/WinMerge/WinMergeU.exe" "$2" "$5" | cat +#"C:/Program Files/KDiff3/kdiff3.exe" "$2" "$5" | cat \ No newline at end of file diff --git a/git-hook-console-log.sh b/git-hook-console-log.sh new file mode 100755 index 0000000..07a8cc3 --- /dev/null +++ b/git-hook-console-log.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +# git diff --cached = stagged changes +# git diff = all changes + +has_console_log=$(git diff --cached | grep -F 'console.log') + +if [ "$has_console_log" != "" ] +then + echo "ERROR: You have console.log in your changes. Consider removing them." + exit 1 +fi + +has_console_log=$(git diff | grep -F 'console.log') + +if [ "$has_console_log" != "" ] +then + echo "ERROR: You have console.log in your changes. Consider removing them." + exit 1 +fi \ No newline at end of file diff --git a/git-hook-trailing-whitespace.sh b/git-hook-trailing-whitespace.sh new file mode 100755 index 0000000..91b664e --- /dev/null +++ b/git-hook-trailing-whitespace.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# source: http://css.dzone.com/articles/all-git-hooks-you-need +# Force remove trailing-whitespaces (and carriage-return in linux) + +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +# Find files with trailing whitespace +for FILE in `exec git diff-index --check --cached $against -- | sed '/^[+-]/d' | cut -f1 -d: | uniq` ; do + # Fix them! + sed -i 's/\s\+$//' "$FILE" + git add "$FILE" +done + +exit \ No newline at end of file diff --git a/git-merge-diffmerge-wrapper.sh b/git-merge-diffmerge-wrapper.sh new file mode 100755 index 0000000..8a3b7c8 --- /dev/null +++ b/git-merge-diffmerge-wrapper.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# Passing the following parameters to mergetool: +# local base remote merge_result + +# params should come as: "$PWD/$LOCAL" "$PWD/$BASE" "$PWD/$REMOTE" "$PWD/$MERGED" +#"C:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" "$1" "$2" "$3" --result="$4" --title1="Mine" --title2="Merging to: $4" --title3="Theirs" +#"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?))" +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?))" diff --git a/git-output.awk b/git-output.awk new file mode 100755 index 0000000..7aa015f --- /dev/null +++ b/git-output.awk @@ -0,0 +1,220 @@ +#!/usr/bin/awk -f +# +# (c) 2011 Brian C. Milco +# +# This script parses the output of several git commands and presents the +# information in one line that can be added to a command prompt (PS1). +# +# If you use -v separator="|" separator2="/" when calling this script you can use other field separators. +# +# Sample output: +# +# | master | ▲ 1 ▼ 1 | 1/2/3/4 |1 +# +# What the output means: +# +# | - field separator +# master - the branch name or (no branch) or (bare repository) +# ▲ 1 - how many commits on this branch not in the remote branch. You need to push changes to remote. +# ▼ 1 - how many commits on the remote branch not in this branch. You need to pull changes from remote. +# 1/2/3/4 - The count of changes in the repository: +# 1 - the number of staged changes. (green) +# 2 - the number of unstaged changes. (yellow) +# 3 - the number of unmerged changes. (magenta) +# 4 - the number of untracked changes. (red) +# |1 - the number of stashed changes. (yellow) +# + +# original code from: +# https://gist.github.com/1266869 + +# old branch symbol: └├ + +function cmd( c ) +{ + while( (c|getline foo) > 0 ) + continue; + close( c ); + return foo; +} + +BEGIN { + #colors: + black="\033[30m"; + dark_gray="\033[01;30m"; + red="\033[31m"; + bright_red="\033[1;31m"; + green="\033[32m"; + bright_green="\033[1;32m"; + yellow="\033[33m"; + bright_yellow="\033[1;33m"; + blue="\033[34m"; + bright_blue="\033[1;34m"; + violet="\033[35m"; + bright_violet="\033[1;35m"; + cyan="\033[036m"; + bright_cyan="\033[1;36m"; + white="\033[37m"; + light_gray="\033[00;37m"; + end_color="\033[0m"; + + if(separator == "") { + separator = "|"; + } + + if(separator2 == "") { + separator2 = "-"; + } + + separator = dark_gray separator end_color; + separator2 = dark_gray separator2 end_color; + + isRepo = 0; + + output = cmd("git rev-parse --git-dir 2> /dev/null"); + + if(output) { + + bareTest = cmd("cat " output "/config | grep \"bare\" 2> /dev/null"); + if(bareTest ~ "true") + bareRepo = 1; + + stashCount = cmd("git stash list | wc -l 2> /dev/null"); + gsub(/ /,"",stashCount); + + isRepo = 1; + } + + changes["staged"] = 0; + changes["unstaged"] = 0; + changes["untracked"] = 0; + changes["unmerged"] = 0; + +} +{ + #only process lines that have data. + if(skip > 0) { + skip--; + next; + } + + test=$1 " " $2 " " $3; + + if(test == "# On branch") { + branch = $4; + next; + } else if(test == "# Changes to") { #staged + skip = 1; + staged = 1; + tracked = 1; + merged = 1; + next; + } else if(test == "# Changes not") { #unstaged + skip = 3; + staged = 0; + tracked = 1; + merged = 1; + next; + } else if(test == "# Untracked files:") {#untracked + skip = 2; + staged = 0; + tracked = 0; + merged = 1; + next; + } else if(test == "# Unmerged paths:") {#unmerged + skip = 2; + staged = 0; + tracked = 1; + merged = 0; + next; + } else if($1 != "#") { + next; + } else if(test == "# Initial commit") { + next; + } else if(test == "# Your branch") { #branch is ahead/behind + + if($5 == "ahead") { + ahead = $9; + } else if($5 == "behind") { + behind = $8; + } + next; + } else if(test == "# and have") { #branches have diverged + ahead = $4; + behind = $6; + next; + } else if(test == "# Not currently") {#detached HEAD + branch = "(no branch)"; + } + + #Don't count blank lines + if($0 == "#") + next; + + if(staged == 1) + changes["staged"] += 1; + else if(staged == 0 && tracked == 1 && merged == 1) + changes["unstaged"] += 1; + else if(tracked == 0) + changes["untracked"] += 1; + else if(merged == 0) + changes["unmerged"] += 1; + +} +END { + + output = ""; + if(isRepo == 1) { + + branchOutput = separator " "; + + if(bareRepo == 1) { + branchOutput = branchOutput bright_cyan "(bare repository)"; + } else { + branchOutput = branchOutput bright_cyan "  " branch; + } + + output = output branchOutput " " separator " "; + + if(bareRepo != 1) { + + if(ahead > 0 || behind > 0) { + if(ahead > 0) { + output = output bright_yellow "▲ " end_color ahead; + } + if (behind > 0) { + output = output bright_yellow "▼ " end_color behind; + } + + output = output " " separator " "; + } + + #if there are changes show the output. + if(changes["staged"] > 0 || changes["unstaged"] > 0 || changes["untracked"] > 0 || changes["unmerged"] > 0) { + + output = output bright_green changes["staged"] end_color; + output = output separator2; + + output = output bright_yellow changes["unstaged"] end_color; + output = output separator2; + + output = output violet changes["unmerged"] end_color; + output = output separator2; + + output = output bright_red changes["untracked"] end_color; + output = output " "; + + } else { + output = output bright_green "√ ☺ " end_color; + } + + if(stashCount > 0) { + output = output separator bright_yellow " {≡" stashCount "} " end_color; + } + } else { + output = output "no branch "; + } + + printf output end_color; + } +} diff --git a/git-prompt.sh b/git-prompt.sh new file mode 100755 index 0000000..f7cd07b --- /dev/null +++ b/git-prompt.sh @@ -0,0 +1,372 @@ +# bash/zsh git prompt support +# +# Copyright (C) 2006,2007 Shawn O. Pearce +# Distributed under the GNU General Public License, version 2.0. +# +# This script allows you to see the current branch in your prompt. +# +# To enable: +# +# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh). +# 2) Add the following line to your .bashrc/.zshrc: +# source ~/.git-prompt.sh +# 3a) In ~/.bashrc set PROMPT_COMMAND=__git_ps1 +# To customize the prompt, provide start/end arguments +# PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "' +# 3b) Alternatively change your PS1 to call __git_ps1 as +# command-substitution: +# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' +# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' +# the optional argument will be used as format string +# +# The argument to __git_ps1 will be displayed only if you are currently +# in a git repository. The %s token will be the name of the current +# branch. +# +# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value, +# unstaged (*) and staged (+) changes will be shown next to the branch +# name. You can configure this per-repository with the +# bash.showDirtyState variable, which defaults to true once +# GIT_PS1_SHOWDIRTYSTATE is enabled. +# +# You can also see if currently something is stashed, by setting +# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed, +# then a '$' will be shown next to the branch name. +# +# If you would like to see if there're untracked files, then you can set +# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked +# files, then a '%' will be shown next to the branch name. +# +# If you would like to see the difference between HEAD and its upstream, +# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">" +# indicates you are ahead, "<>" indicates you have diverged and "=" +# indicates that there is no difference. You can further control +# behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list +# of values: +# +# verbose show number of commits ahead/behind (+/-) upstream +# legacy don't use the '--count' option available in recent +# versions of git-rev-list +# git always compare HEAD to @{upstream} +# svn always compare HEAD to your SVN upstream +# +# By default, __git_ps1 will compare HEAD to your SVN upstream if it can +# find one, or @{upstream} otherwise. Once you have set +# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by +# setting the bash.showUpstream config variable. +# +# If you would like a colored hint about the current dirty state, set +# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on +# the colored output of "git status -sb". +# +# __gitdir accepts 0 or 1 arguments (i.e., location) +# returns location of .git repo +__gitdir () +{ + # Note: this function is duplicated in git-completion.bash + # When updating it, make sure you update the other one to match. + if [ -z "${1-}" ]; then + if [ -n "${__git_dir-}" ]; then + echo "$__git_dir" + elif [ -n "${GIT_DIR-}" ]; then + test -d "${GIT_DIR-}" || return 1 + echo "$GIT_DIR" + elif [ -d .git ]; then + echo .git + else + git rev-parse --git-dir 2>/dev/null + fi + elif [ -d "$1/.git" ]; then + echo "$1/.git" + else + echo "$1" + fi +} + +# stores the divergence from upstream in $p +# used by GIT_PS1_SHOWUPSTREAM +__git_ps1_show_upstream () +{ + local key value + local svn_remote svn_url_pattern count n + local upstream=git legacy="" verbose="" + + svn_remote=() + # get some config options from git-config + local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')" + while read -r key value; do + case "$key" in + bash.showupstream) + GIT_PS1_SHOWUPSTREAM="$value" + if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then + p="" + return + fi + ;; + svn-remote.*.url) + svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value" + svn_url_pattern+="\\|$value" + upstream=svn+git # default upstream is SVN if available, else git + ;; + esac + done <<< "$output" + + # parse configuration values + for option in ${GIT_PS1_SHOWUPSTREAM}; do + case "$option" in + git|svn) upstream="$option" ;; + verbose) verbose=1 ;; + legacy) legacy=1 ;; + esac + done + + # Find our upstream + case "$upstream" in + git) upstream="@{upstream}" ;; + svn*) + # get the upstream from the "git-svn-id: ..." in a commit message + # (git-svn uses essentially the same procedure internally) + local svn_upstream=($(git log --first-parent -1 \ + --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null)) + if [[ 0 -ne ${#svn_upstream[@]} ]]; then + svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]} + svn_upstream=${svn_upstream%@*} + local n_stop="${#svn_remote[@]}" + for ((n=1; n <= n_stop; n++)); do + svn_upstream=${svn_upstream#${svn_remote[$n]}} + done + + if [[ -z "$svn_upstream" ]]; then + # default branch name for checkouts with no layout: + upstream=${GIT_SVN_ID:-git-svn} + else + upstream=${svn_upstream#/} + fi + elif [[ "svn+git" = "$upstream" ]]; then + upstream="@{upstream}" + fi + ;; + esac + + # Find how many commits we are ahead/behind our upstream + if [[ -z "$legacy" ]]; then + count="$(git rev-list --count --left-right \ + "$upstream"...HEAD 2>/dev/null)" + else + # produce equivalent output to --count for older versions of git + local commits + if commits="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null)" + then + local commit behind=0 ahead=0 + for commit in $commits + do + case "$commit" in + "<"*) ((behind++)) ;; + *) ((ahead++)) ;; + esac + done + count="$behind $ahead" + else + count="" + fi + fi + + # calculate the result + if [[ -z "$verbose" ]]; then + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p="=" ;; + "0 "*) # ahead of upstream + p=">" ;; + *" 0") # behind upstream + p="<" ;; + *) # diverged from upstream + p="<>" ;; + esac + else + case "$count" in + "") # no upstream + p="" ;; + "0 0") # equal to upstream + p=" u=" ;; + "0 "*) # ahead of upstream + p=" u+${count#0 }" ;; + *" 0") # behind upstream + p=" u-${count% 0}" ;; + *) # diverged from upstream + p=" u+${count#* }-${count% *}" ;; + esac + fi + +} + + +# __git_ps1 accepts 0 or 1 arguments (i.e., format string) +# when called from PS1 using command substitution +# in this mode it prints text to add to bash PS1 prompt (includes branch name) +# +# __git_ps1 requires 2 arguments when called from PROMPT_COMMAND (pc) +# in that case it _sets_ PS1. The arguments are parts of a PS1 string. +# when both arguments are given, the first is prepended and the second appended +# to the state string when assigned to PS1. +# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true +__git_ps1 () +{ + local pcmode=no + local detached=no + local ps1pc_start='\u@\h:\w ' + local ps1pc_end='\$ ' + local printf_format=' (%s)' + + case "$#" in + 2) pcmode=yes + ps1pc_start="$1" + ps1pc_end="$2" + ;; + 0|1) printf_format="${1:-$printf_format}" + ;; + *) return + ;; + esac + + local g="$(__gitdir)" + if [ -z "$g" ]; then + if [ $pcmode = yes ]; then + #In PC mode PS1 always needs to be set + PS1="$ps1pc_start$ps1pc_end" + fi + else + local r="" + local b="" + if [ -f "$g/rebase-merge/interactive" ]; then + r="|REBASE-i" + b="$(cat "$g/rebase-merge/head-name")" + elif [ -d "$g/rebase-merge" ]; then + r="|REBASE-m" + b="$(cat "$g/rebase-merge/head-name")" + else + if [ -d "$g/rebase-apply" ]; then + if [ -f "$g/rebase-apply/rebasing" ]; then + r="|REBASE" + elif [ -f "$g/rebase-apply/applying" ]; then + r="|AM" + else + r="|AM/REBASE" + fi + elif [ -f "$g/MERGE_HEAD" ]; then + r="|MERGING" + elif [ -f "$g/CHERRY_PICK_HEAD" ]; then + r="|CHERRY-PICKING" + elif [ -f "$g/BISECT_LOG" ]; then + r="|BISECTING" + fi + + b="$(git symbolic-ref HEAD 2>/dev/null)" || { + detached=yes + b="$( + case "${GIT_PS1_DESCRIBE_STYLE-}" in + (contains) + git describe --contains HEAD ;; + (branch) + git describe --contains --all HEAD ;; + (describe) + git describe HEAD ;; + (* | default) + git describe --tags --exact-match HEAD ;; + esac 2>/dev/null)" || + + b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." || + b="unknown" + b="($b)" + } + fi + + local w="" + local i="" + local s="" + local u="" + local c="" + local p="" + + if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then + if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then + c="BARE:" + else + b="GIT_DIR!" + fi + elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then + if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then + if [ "$(git config --bool bash.showDirtyState)" != "false" ]; then + git diff --no-ext-diff --quiet --exit-code || w="*" + if git rev-parse --quiet --verify HEAD >/dev/null; then + git diff-index --cached --quiet HEAD -- || i="+" + else + i="#" + fi + fi + fi + if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then + git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$" + fi + + if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then + if [ -n "$(git ls-files --others --exclude-standard)" ]; then + u="%" + fi + fi + + if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then + __git_ps1_show_upstream + fi + fi + + local f="$w$i$s$u" + if [ $pcmode = yes ]; then + if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then + local c_red='\e[31m' + local c_green='\e[32m' + local c_lblue='\e[1;34m' + local c_clear='\e[0m' + local bad_color=$c_red + local ok_color=$c_green + local branch_color="$c_clear" + local flags_color="$c_lblue" + local branchstring="$c${b##refs/heads/}" + + if [ $detached = no ]; then + branch_color="$ok_color" + else + branch_color="$bad_color" + fi + + # Setting PS1 directly with \[ and \] around colors + # is necessary to prevent wrapping issues! + PS1="$ps1pc_start (\[$branch_color\]$branchstring\[$c_clear\]" + + if [ -n "$w$i$s$u$r$p" ]; then + PS1="$PS1 " + fi + if [ "$w" = "*" ]; then + PS1="$PS1\[$bad_color\]$w" + fi + if [ -n "$i" ]; then + PS1="$PS1\[$ok_color\]$i" + fi + if [ -n "$s" ]; then + PS1="$PS1\[$flags_color\]$s" + fi + if [ -n "$u" ]; then + PS1="$PS1\[$bad_color\]$u" + fi + PS1="$PS1\[$c_clear\]$r$p)$ps1pc_end" + else + PS1="$ps1pc_start ($c${b##refs/heads/}${f:+ $f}$r$p)$ps1pc_end" + fi + else + # NO color option unless in PROMPT_COMMAND mode + printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p" + fi + fi +} \ No newline at end of file diff --git a/grep-examples.sh b/grep-examples.sh new file mode 100644 index 0000000..c5c776b --- /dev/null +++ b/grep-examples.sh @@ -0,0 +1,3 @@ +# search for 'audience' AND 'segment' +# http://stackoverflow.com/questions/4795323/grep-for-multiple-strings-in-file-on-different-lines-ie-whole-file-not-line-b +grep -iIrnl audience * | xargs grep -iIrnl segment diff --git a/grep-search-bad-things-code-check.sh b/grep-search-bad-things-code-check.sh new file mode 100755 index 0000000..ac0b154 --- /dev/null +++ b/grep-search-bad-things-code-check.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# first attempt + +# grep -rin -e 'console\.log\|debugger' ./web/js/ # to dependent on file structure + +# second attempt + +# http://www.daniweb.com/community-center/it-professionals-lounge/threads/85626 + +# Which translates in english to.. search (find) in this folder (.) for files matching the filter ( -name ) *.php [ recursiveness should be default ]; when each file is found, execute grep, look for 'some_string', and pass in the found filename ( where the {} placeholder is ). Because that effectively executes grep once per file ( rather than once for many files ), you need the -H option to force grep to turn on the output of the filename; it wouldn't bother otherwise for a single file grep. + +find . -name "*.js" -exec grep -rinH -e 'console\.log\|debugger' {} \; \ No newline at end of file diff --git a/ipenguin-git-output-parse-bash-prompt.sh b/ipenguin-git-output-parse-bash-prompt.sh new file mode 100755 index 0000000..94e5cef --- /dev/null +++ b/ipenguin-git-output-parse-bash-prompt.sh @@ -0,0 +1,36 @@ +#The following lines should be added to your .bashrc file to use the git-output.awk file + +# ⚫ ❨ ❩ ▲ ⬇ ⑈ ⑉ ǁ» ║ ⑆ ⑇ ⟅ ⟆ ⬅ ➤ ➥ ➦ ➡ +SEPARATOR="‡" +SEPARATOR2="|" + + +function parse_git_output { + + output=$(git status 2> /dev/null | ~/Bash-Scripts/git-output.awk -v separator=$SEPARATOR separator2=$SEPARATOR2 2> /dev/null) || return + echo -e "$output"; +} + +BLACK="\[\e[00;30m\]" +DARY_GRAY="\[\e[01;30m\]" +RED="\[\e[00;31m\]" +BRIGHT_RED="\[\e[01;31m\]" +GREEN="\[\e[00;32m\]" +BRIGHT_GREEN="\[\e[01;32m\]" +BROWN="\[\e[00;33m\]" +YELLOW="\[\e[01;33m\]" +BLUE="\[\e[00;34m\]" +BRIGHT_BLUE="\[\e[01;34m\]" +PURPLE="\[\e[00;35m\]" +LIGHT_PURPLE="\[\e[01;35m\]" +CYAN="\[\e[00;36m\]" +BRIGHT_CYAN="\[\e[01;36m\]" +LIGHT_GRAY="\[\e[00;37m\]" +WHITE="\[\e[01;37m\]" +ENDCOLOR="\e[m" + +if [ "$SSH_CONNECTION" == "" ]; then + PS1="${BRIGHT_RED}#--[ ${GREEN}\h ${DARY_GRAY}${SEPARATOR} ${BRIGHT_BLUE}\w \$(parse_git_output)${BRIGHT_RED}]\\$ -->${ENDCOLOR}\n" +else + PS1="${BRIGHT_RED}#--[ ${YELLOW}\h ${DARY_GRAY}${SEPARATOR} ${BRIGHT_BLUE}\w \$(parse_git_output)${BRIGHT_RED}]\\$ -->${ENDCOLOR}\n" +fi diff --git a/ipenguin-git-output-parse-bash-prompt.txt b/ipenguin-git-output-parse-bash-prompt.txt new file mode 100644 index 0000000..e479736 --- /dev/null +++ b/ipenguin-git-output-parse-bash-prompt.txt @@ -0,0 +1,35 @@ +#The following lines should be added to your .bashrc file to use the git-output.awk file + +# ⚫ ❨ ❩ ▲ ⬇ ⑈ ⑉ ǁ ║ ⑆ ⑇ ⟅ ⟆ ⬅ ➤ ➥ ➦ ➡ +SEPARATOR="ǁ" +SEPARATOR2="║" + +function parse_git_output { + + output=$(git status 2> /dev/null | git.awk -v separator=$SEPARATOR separator2=$SEPARATOR2 2> /dev/null) || return + echo -e "$output"; +} + +BLACK="\[\e[00;30m\]" +DARY_GRAY="\[\e[01;30m\]" +RED="\[\e[00;31m\]" +BRIGHT_RED="\[\e[01;31m\]" +GREEN="\[\e[00;32m\]" +BRIGHT_GREEN="\[\e[01;32m\]" +BROWN="\[\e[00;33m\]" +YELLOW="\[\e[01;33m\]" +BLUE="\[\e[00;34m\]" +BRIGHT_BLUE="\[\e[01;34m\]" +PURPLE="\[\e[00;35m\]" +LIGHT_PURPLE="\[\e[01;35m\]" +CYAN="\[\e[00;36m\]" +BRIGHT_CYAN="\[\e[01;36m\]" +LIGHT_GRAY="\[\e[00;37m\]" +WHITE="\[\e[01;37m\]" +ENDCOLOR="\e[m" + +if [ "$SSH_CONNECTION" == "" ]; then + PS1="${BRIGHT_RED}#--[ ${GREEN}\h ${DARY_GRAY}${SEPARATOR} ${BRIGHT_BLUE}\w \$(parse_git_output)${BRIGHT_RED}]\\$ --≻${ENDCOLOR}\n" +else + PS1="${BRIGHT_RED}#--[ ${YELLOW}\h ${DARY_GRAY}${SEPARATOR} ${BRIGHT_BLUE}\w \$(parse_git_output)${BRIGHT_RED}]\\$ --≻${ENDCOLOR}\n" +fi \ No newline at end of file diff --git a/make-folders-a-z.sh b/make-folders-a-z.sh new file mode 100755 index 0000000..21e20ce --- /dev/null +++ b/make-folders-a-z.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# make folders a through z + +for i in {A..Z};do mkdir $i;done \ No newline at end of file diff --git a/move-files-to-a-z-folders.sh b/move-files-to-a-z-folders.sh new file mode 100755 index 0000000..e51d201 --- /dev/null +++ b/move-files-to-a-z-folders.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# move files beginning w/ A..Z to A..Z folders + +# wont work for filetypes (does all): +#for f in * +# do dangerous and complicated: +#for f in 'ls' +for f in *; do + if [ -f "$f" ] + then + #echo "$f file"; + FIRST_CHAR=${f:0:1}; + #echo "first char = $FIRST_CHAR"; + #FIRST_CHAR_UPPER=$FIRST_CHAR | tr [:lower:] [:upper:]; + FIRST_CHAR_UPPER=$(echo "$FIRST_CHAR" | tr [:lower:] [:upper:]); + #echo "mv \"$f\" \"$FIRST_CHAR_UPPER/$f\""; + mv "$f" "$FIRST_CHAR_UPPER/$f"; + else + echo "skipping $f not a file"; + fi +done \ No newline at end of file diff --git a/move-to-next-monitor b/move-to-next-monitor new file mode 100755 index 0000000..7ddb6b0 --- /dev/null +++ b/move-to-next-monitor @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Move the current window to the next monitor. +# +# Only works on a horizontal monitor setup. +# Also works only on one X screen (which is the most common case). +# +# Props to +# http://icyrock.com/blog/2012/05/xubuntu-moving-windows-between-monitors/ +# +# Unfortunately, both "xdotool getwindowgeometry --shell $window_id" and +# checking "-geometry" of "xwininfo -id $window_id" are not sufficient, as +# the first command does not respect panel/decoration offsets and the second +# will sometimes give a "-0-0" geometry. This is why we resort to "xwininfo". + +screen_width=`xdpyinfo | awk '/dimensions:/ { print $2; exit }' | cut -d"x" -f1` +display_width=`xdotool getdisplaygeometry | cut -d" " -f1` +window_id=`xdotool getactivewindow` + +# Remember if it was maximized. +window_state=`xprop -id $window_id _NET_WM_STATE | awk '{ print $3 }'` + +# Un-maximize current window so that we can move it +wmctrl -ir $window_id -b remove,maximized_vert,maximized_horz + +# Read window position +x=`xwininfo -id $window_id | awk '/Absolute upper-left X:/ { print $4 }'` +y=`xwininfo -id $window_id | awk '/Absolute upper-left Y:/ { print $4 }'` + +# Subtract any offsets caused by panels or window decorations +x_offset=`xwininfo -id $window_id | awk '/Relative upper-left X:/ { print $4 }'` +y_offset=`xwininfo -id $window_id | awk '/Relative upper-left Y:/ { print $4 }'` +x=`expr $x - $x_offset` +y=`expr $y - $y_offset` + +# Compute new X position +new_x=`expr $x + $display_width` + +# If we would move off the right-most monitor, we set it to the left one. +# We also respect the window's width here: moving a window off more than half its width won't happen. +width=`xdotool getwindowgeometry $window_id | awk '/Geometry:/ { print $2 }'|cut -d"x" -f1` +if [ `expr $new_x + $width / 2` -gt $screen_width ]; then + new_x=`expr $new_x - $screen_width` +fi + +# Don't move off the left side. +if [ $new_x -lt 0 ]; then + new_x=0 +fi + +# Move the window +xdotool windowmove $window_id $new_x $y + +# Maximize window again, if it was before +if [ -n "${window_state}" ]; then + wmctrl -ir $window_id -b add,maximized_vert,maximized_horz +fi diff --git a/remove-console-from-js.sh b/remove-console-from-js.sh new file mode 100755 index 0000000..be97829 --- /dev/null +++ b/remove-console-from-js.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# http://stackoverflow.com/questions/6595429/using-sed-to-remove-all-console-log-from-javascript-file +# http://tille.garrels.be/training/bash/ch07s02.html (bash help) + +# sed usage example: +# sed -e 's/SEARCH_STRING/REPLACE_STRING/g' file > file.out +# have to escape all / (forward slashes) because has special meaning in sed +SEARCH_STRING="(\/\/)*console.(log|debug|info|warn|error|assert|dir|dirxml|trace|group|groupEnd|time|timeEnd|profile|profileEnd|count)\((.*)\);?" +REPLACE_STRING="" + +if [ ! $# == 1 ]; then + echo "Must provide 1 argument (the file to modify)" +elif [ ! -f $1 ]; then + echo "This thing you passed is not a file or cannot be found!" +else + echo "Modifying file!" + #sed -E "s/$SEARCH_STRING/$REPLACE_STRING/g" $1 > "$1.tmp" + sed -E "/$SEARCH_STRING/ d" $1 > "$1.tmp" + cp "$1.tmp" $1 + rm "$1.tmp" +fi + +echo "Complete" \ No newline at end of file diff --git a/shutdown.sh b/shutdown.sh new file mode 100755 index 0000000..8353a34 --- /dev/null +++ b/shutdown.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# https://www.google.com/search?ix=iea&sourceid=chrome&ie=UTF-8&q=cygwin+cron +# http://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows + + +#cd /cygdrive/c/Development/Bash-Scripts/ + +#./backup.sh + +./cygdrive/c/Users/Ryan/Bash-Scripts/backup.sh + +exit 0 \ No newline at end of file diff --git a/start-xampp.sh b/start-xampp.sh new file mode 100755 index 0000000..16dfe98 --- /dev/null +++ b/start-xampp.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# https://gist.github.com/gmmorris/796400 +sudo pkill -9 apache +# now start it +sudo /opt/lampp/lampp start diff --git a/tail-color-log.sh b/tail-color-log.sh new file mode 100755 index 0000000..a57678c --- /dev/null +++ b/tail-color-log.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# @author Ryan McIntyre + +# log like: /c/wamp/www/proto/portal/log/frontend_local.log + +ME="$(basename "$(test -L "$0" && readlink "$0" || echo "$0")")" +MY_DIR=`dirname $0` + +if [ -e $MY_DIR/unix-color-codes-not-escaped.sh ]; then + . $MY_DIR/unix-color-codes-not-escaped.sh +fi + +if [ $# == 0 ]; then + echo -e "${On_Red}No log file given, usage: $ME ${Color_Off}" + exit 1 +else + LOG_FILE=$1 + echo "Showing tail of: $LOG_FILE" +fi + +tail -f $LOG_FILE | awk ' + /200 OK/ {print "\033[32m" $0 "\033[39m"; next} + /View "Success"/ {print "\033[33m" $0 "\033[39m"; next} + /sfPatternRouting/ {print "\033[35m" $0 "\033[39m"; next} + /Doctrine_Connection/ {print "\033[36m" $0 "\033[39m"; next} + /err/ {print "\033[31m" $0 "\033[39m"; next} + /severe/ {print "\033[31m" $0 "\033[39m"; next} + /debug/ {print "\033[34m" $0 "\033[39m"; next} + 1 {print} +' + +# sources: + +## http://stackoverflow.com/questions/192292/bash-how-best-to-include-other-scripts diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..20ba999 --- /dev/null +++ b/test.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +echo "test" + +echo "test params" + +POSTFIX_NAME="_"$1 + +if [ $# != 0 ]; then + echo 'postfix name given:' $POSTFIX_NAME +else + echo 'no input' +fi + +exit 0 + diff --git a/touchoff.sh b/touchoff.sh new file mode 100755 index 0000000..86f83eb --- /dev/null +++ b/touchoff.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# thank you: http://www.linuxquestions.org/questions/debian-26/shmconfig-in-debian-645503/#post3838794 +# script to turn off touchpad if mouse present at login +# synclient is the synaptic utility to manage the touchpad +# grep the "lsusb" output and do a wordcount on number of lines with "Logitech" which should = 1 if a Logitech mouse is present +# +# Obviously the "Logitech" should be replaced with your brand of mouse, and perhaps be more exact in case you have other USB devices that have similar names + +# I found on: http://crunchbang.org/forums/viewtopic.php?id=15992 + +/usr/bin/synclient touchpadoff=`lsusb | grep Logitech | wc -l` diff --git a/ultimate-git-ps1-bash-prompt.sh b/ultimate-git-ps1-bash-prompt.sh new file mode 100755 index 0000000..01236a0 --- /dev/null +++ b/ultimate-git-ps1-bash-prompt.sh @@ -0,0 +1,109 @@ +# original source: +# http://mediadoneright.com/content/ultimate-git-ps1-bash-prompt + +# Customize BASH PS1 prompt to show current GIT repository and branch. +# by Mike Stewart - http://MediaDoneRight.com + +# SETUP CONSTANTS +# Bunch-o-predefined colors. Makes reading code easier than escape sequences. +# I don't remember where I found this. o_O + +# Reset +Color_Off="\[\033[0m\]" # Text Reset + +# Regular Colors +Black="\[\033[0;30m\]" # Black +Red="\[\033[0;31m\]" # Red +Green="\[\033[0;32m\]" # Green +Yellow="\[\033[0;33m\]" # Yellow +Blue="\[\033[0;34m\]" # Blue +Purple="\[\033[0;35m\]" # Purple +Cyan="\[\033[0;36m\]" # Cyan +White="\[\033[0;37m\]" # White + +# Bold +BBlack="\[\033[1;30m\]" # Black +BRed="\[\033[1;31m\]" # Red +BGreen="\[\033[1;32m\]" # Green +BYellow="\[\033[1;33m\]" # Yellow +BBlue="\[\033[1;34m\]" # Blue +BPurple="\[\033[1;35m\]" # Purple +BCyan="\[\033[1;36m\]" # Cyan +BWhite="\[\033[1;37m\]" # White + +# Underline +UBlack="\[\033[4;30m\]" # Black +URed="\[\033[4;31m\]" # Red +UGreen="\[\033[4;32m\]" # Green +UYellow="\[\033[4;33m\]" # Yellow +UBlue="\[\033[4;34m\]" # Blue +UPurple="\[\033[4;35m\]" # Purple +UCyan="\[\033[4;36m\]" # Cyan +UWhite="\[\033[4;37m\]" # White + +# Background +On_Black="\[\033[40m\]" # Black +On_Red="\[\033[41m\]" # Red +On_Green="\[\033[42m\]" # Green +On_Yellow="\[\033[43m\]" # Yellow +On_Blue="\[\033[44m\]" # Blue +On_Purple="\[\033[45m\]" # Purple +On_Cyan="\[\033[46m\]" # Cyan +On_White="\[\033[47m\]" # White + +# High Intensty +IBlack="\[\033[0;90m\]" # Black +IRed="\[\033[0;91m\]" # Red +IGreen="\[\033[0;92m\]" # Green +IYellow="\[\033[0;93m\]" # Yellow +IBlue="\[\033[0;94m\]" # Blue +IPurple="\[\033[0;95m\]" # Purple +ICyan="\[\033[0;96m\]" # Cyan +IWhite="\[\033[0;97m\]" # White + +# Bold High Intensty +BIBlack="\[\033[1;90m\]" # Black +BIRed="\[\033[1;91m\]" # Red +BIGreen="\[\033[1;92m\]" # Green +BIYellow="\[\033[1;93m\]" # Yellow +BIBlue="\[\033[1;94m\]" # Blue +BIPurple="\[\033[1;95m\]" # Purple +BICyan="\[\033[1;96m\]" # Cyan +BIWhite="\[\033[1;97m\]" # White + +# High Intensty backgrounds +On_IBlack="\[\033[0;100m\]" # Black +On_IRed="\[\033[0;101m\]" # Red +On_IGreen="\[\033[0;102m\]" # Green +On_IYellow="\[\033[0;103m\]" # Yellow +On_IBlue="\[\033[0;104m\]" # Blue +On_IPurple="\[\033[10;95m\]" # Purple +On_ICyan="\[\033[0;106m\]" # Cyan +On_IWhite="\[\033[0;107m\]" # White + +# Various variables you might want for your PS1 prompt instead +Time12h="\T" +Time12a="\@" +PathShort="\w" +PathFull="\W" +NewLine="\n" +Jobs="\j" + + +# This PS1 snippet was adopted from code for MAC/BSD I saw from: http://allancraig.net/index.php?option=com_content&view=article&id=108:ps1-export-command-for-git&catid=45:general&Itemid=96 +# I tweaked it to work on UBUNTU 11.04 & 11.10 plus made it mo' better + +export PS1=$Green$Time12h$Color_Off'$(git branch &>/dev/null;\ +if [ $? -eq 0 ]; then \ + echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \ + if [ "$?" -eq "0" ]; then \ + # @4 - Clean repository - nothing to commit + echo "'$Green'"$(__git_ps1 " (%s)"); \ + else \ + # @5 - Changes to working tree + echo "'$BRed$On_Red'"$(__git_ps1 " {%s}*"); \ + fi) '$Color_Off$BYellow$PathShort$Color_Off'\$ "; \ +else \ + # @2 - Prompt when not in GIT repo + echo " '$BYellow$PathShort$Color_Off'\$ "; \ +fi)' diff --git a/unix-color-codes-not-escaped.sh b/unix-color-codes-not-escaped.sh new file mode 100755 index 0000000..9b296fe --- /dev/null +++ b/unix-color-codes-not-escaped.sh @@ -0,0 +1,102 @@ + + +# Reset +Color_Off="\033[0m" # Text Reset + +# Regular Colors +Black="\033[0;30m" # Black +Red="\033[0;31m" # Red +Green="\033[0;32m" # Green +Yellow="\033[0;33m" # Yellow +Blue="\033[0;34m" # Blue +Purple="\033[0;35m" # Purple +Cyan="\033[0;36m" # Cyan +White="\033[0;37m" # White + +# Bold +BBlack="\033[1;30m" # Black +BRed="\033[1;31m" # Red +BGreen="\033[1;32m" # Green +BYellow="\033[1;33m" # Yellow +BBlue="\033[1;34m" # Blue +BPurple="\033[1;35m" # Purple +BCyan="\033[1;36m" # Cyan +BWhite="\033[1;37m" # White + +# Underline +UBlack="\033[4;30m" # Black +URed="\033[4;31m" # Red +UGreen="\033[4;32m" # Green +UYellow="\033[4;33m" # Yellow +UBlue="\033[4;34m" # Blue +UPurple="\033[4;35m" # Purple +UCyan="\033[4;36m" # Cyan +UWhite="\033[4;37m" # White + +# Background +On_Black="\033[40m" # Black +On_Red="\033[41m" # Red +On_Green="\033[42m" # Green +On_Yellow="\033[43m" # Yellow +On_Blue="\033[44m" # Blue +On_Purple="\033[45m" # Purple +On_Cyan="\033[46m" # Cyan +On_White="\033[47m" # White + +# High Intensty +IBlack="\033[0;90m" # Black +IRed="\033[0;91m" # Red +IGreen="\033[0;92m" # Green +IYellow="\033[0;93m" # Yellow +IBlue="\033[0;94m" # Blue +IPurple="\033[0;95m" # Purple +ICyan="\033[0;96m" # Cyan +IWhite="\033[0;97m" # White + +# Bold High Intensty +BIBlack="\033[1;90m" # Black +BIRed="\033[1;91m" # Red +BIGreen="\033[1;92m" # Green +BIYellow="\033[1;93m" # Yellow +BIBlue="\033[1;94m" # Blue +BIPurple="\033[1;95m" # Purple +BICyan="\033[1;96m" # Cyan +BIWhite="\033[1;97m" # White + +# High Intensty backgrounds +On_IBlack="\033[0;100m" # Black +On_IRed="\033[0;101m" # Red +On_IGreen="\033[0;102m" # Green +On_IYellow="\033[0;103m" # Yellow +On_IBlue="\033[0;104m" # Blue +On_IPurple="\033[10;95m" # Purple +On_ICyan="\033[0;106m" # Cyan +On_IWhite="\033[0;107m" # White + + + +BLACK="\e[00;30m" +DARY_GRAY="\e[01;30m" +RED="\e[00;31m" +BRIGHT_RED="\e[01;31m" +GREEN="\e[00;32m" +BRIGHT_GREEN="\e[01;32m" +BROWN="\e[00;33m" +YELLOW="\e[01;33m" +BLUE="\e[00;34m" +BRIGHT_BLUE="\e[01;34m" +PURPLE="\e[00;35m" +LIGHT_PURPLE="\e[01;35m" +CYAN="\e[00;36m" +BRIGHT_CYAN="\e[01;36m" +LIGHT_GRAY="\e[00;37m" +WHITE="\e[01;37m" +ENDCOLOR="\e[m" + +# sample FOO="${GREEN}bar${ENDCOLOR}" +# OR +# echo echo -e "\e[00;32mfoo\e[mbar" +# OR +# echo -e "\033[0;42m hi \033[0m" +# OR +# echo -e "${On_Green} hi${Color_Off} man" \ No newline at end of file diff --git a/unix-color-codes.sh b/unix-color-codes.sh new file mode 100755 index 0000000..663aed4 --- /dev/null +++ b/unix-color-codes.sh @@ -0,0 +1,102 @@ + + +# Reset +Color_Off="\[\033[0m\]" # Text Reset + +# Regular Colors +Black="\[\033[0;30m\]" # Black +Red="\[\033[0;31m\]" # Red +Green="\[\033[0;32m\]" # Green +Yellow="\[\033[0;33m\]" # Yellow +Blue="\[\033[0;34m\]" # Blue +Purple="\[\033[0;35m\]" # Purple +Cyan="\[\033[0;36m\]" # Cyan +White="\[\033[0;37m\]" # White + +# Bold +BBlack="\[\033[1;30m\]" # Black +BRed="\[\033[1;31m\]" # Red +BGreen="\[\033[1;32m\]" # Green +BYellow="\[\033[1;33m\]" # Yellow +BBlue="\[\033[1;34m\]" # Blue +BPurple="\[\033[1;35m\]" # Purple +BCyan="\[\033[1;36m\]" # Cyan +BWhite="\[\033[1;37m\]" # White + +# Underline +UBlack="\[\033[4;30m\]" # Black +URed="\[\033[4;31m\]" # Red +UGreen="\[\033[4;32m\]" # Green +UYellow="\[\033[4;33m\]" # Yellow +UBlue="\[\033[4;34m\]" # Blue +UPurple="\[\033[4;35m\]" # Purple +UCyan="\[\033[4;36m\]" # Cyan +UWhite="\[\033[4;37m\]" # White + +# Background +On_Black="\[\033[40m\]" # Black +On_Red="\[\033[41m\]" # Red +On_Green="\[\033[42m\]" # Green +On_Yellow="\[\033[43m\]" # Yellow +On_Blue="\[\033[44m\]" # Blue +On_Purple="\[\033[45m\]" # Purple +On_Cyan="\[\033[46m\]" # Cyan +On_White="\[\033[47m\]" # White + +# High Intensty +IBlack="\[\033[0;90m\]" # Black +IRed="\[\033[0;91m\]" # Red +IGreen="\[\033[0;92m\]" # Green +IYellow="\[\033[0;93m\]" # Yellow +IBlue="\[\033[0;94m\]" # Blue +IPurple="\[\033[0;95m\]" # Purple +ICyan="\[\033[0;96m\]" # Cyan +IWhite="\[\033[0;97m\]" # White + +# Bold High Intensty +BIBlack="\[\033[1;90m\]" # Black +BIRed="\[\033[1;91m\]" # Red +BIGreen="\[\033[1;92m\]" # Green +BIYellow="\[\033[1;93m\]" # Yellow +BIBlue="\[\033[1;94m\]" # Blue +BIPurple="\[\033[1;95m\]" # Purple +BICyan="\[\033[1;96m\]" # Cyan +BIWhite="\[\033[1;97m\]" # White + +# High Intensty backgrounds +On_IBlack="\[\033[0;100m\]" # Black +On_IRed="\[\033[0;101m\]" # Red +On_IGreen="\[\033[0;102m\]" # Green +On_IYellow="\[\033[0;103m\]" # Yellow +On_IBlue="\[\033[0;104m\]" # Blue +On_IPurple="\[\033[10;95m\]" # Purple +On_ICyan="\[\033[0;106m\]" # Cyan +On_IWhite="\[\033[0;107m\]" # White + + + +BLACK="\[\e[00;30m\]" +DARY_GRAY="\[\e[01;30m\]" +RED="\[\e[00;31m\]" +BRIGHT_RED="\[\e[01;31m\]" +GREEN="\[\e[00;32m\]" +BRIGHT_GREEN="\[\e[01;32m\]" +BROWN="\[\e[00;33m\]" +YELLOW="\[\e[01;33m\]" +BLUE="\[\e[00;34m\]" +BRIGHT_BLUE="\[\e[01;34m\]" +PURPLE="\[\e[00;35m\]" +LIGHT_PURPLE="\[\e[01;35m\]" +CYAN="\[\e[00;36m\]" +BRIGHT_CYAN="\[\e[01;36m\]" +LIGHT_GRAY="\[\e[00;37m\]" +WHITE="\[\e[01;37m\]" +ENDCOLOR="\e[m" + +# sample FOO="${GREEN}bar${ENDCOLOR}" +# OR +# echo echo -e "\e[00;32mfoo\e[mbar" +# OR +# echo -e "\033[0;42m hi \033[0m" +# OR +# echo -e "${On_Green} hi${Color_Off} man" \ No newline at end of file diff --git a/windows-tasklist.sh b/windows-tasklist.sh new file mode 100755 index 0000000..beeb33f --- /dev/null +++ b/windows-tasklist.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +echo 'tasklist, show high memory usage tasks' + +# this could be useful in use with Samurize + +tasklist /FI "MEMUSAGE gt 100000" \ No newline at end of file diff --git a/winmerge.sh b/winmerge.sh new file mode 100644 index 0000000..4ae019f --- /dev/null +++ b/winmerge.sh @@ -0,0 +1,5 @@ +#!/bin/sh +# http://stackoverflow.com/questions/1881594/use-winmerge-inside-of-git-to-file-diff +echo Launching WinMergeU.exe: $1 $2 +#"$PROGRAMFILES/WinMerge/WinMergeU.exe" -e -ub -dl "Base" -dr "Mine" "$1" "$2" +"C:\Development/WinMerge/WinMergeU.exe" -e -ub -dl "Base" -dr "Mine" "$1" "$2" \ No newline at end of file