Skip to content

Commit

Permalink
Got install script working acceptably.
Browse files Browse the repository at this point in the history
  • Loading branch information
pcummuskey committed Oct 15, 2015
1 parent f407b25 commit c679a11
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
17 changes: 10 additions & 7 deletions bin/git-scripts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/bin/sh

loc="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
repodir=$HOME/.git/script-repos
bindir=$HOME/.git/script-bin

# ===== FUNCTION DEFINITIONS =================

Expand All @@ -22,7 +24,7 @@ function get {
fi

echo "Retrieving ${reponame}@${branchname} from github..."
repo_dir="${loc}/../repos/${reponame}/.git"
repo_dir="${repodir}/${reponame}"

#check if not cloned.
if [ ! -d "$repo_dir/.git" ]; then
Expand All @@ -46,8 +48,9 @@ function on {
scriptpath=$2
scriptname=$3

echo Creating symlink for ${loc}/../repos/$reponame/$scriptpath to ${loc}/$scriptname
ln -s "${loc}/../repos/$reponame/$scriptpath" $scriptname
mkdir -p ${bindir}
echo Creating symlink for ${repodir}/$reponame/$scriptpath to ${bindir}/$scriptname
ln -s "${repodir}/$reponame/$scriptpath" ${bindir}/$scriptname

}

Expand All @@ -57,7 +60,7 @@ function off {
scriptname=$1

echo Removing ${scriptname} from active scripts
rm -f "${loc}/${scriptname}"
rm -f "${bindir}/${scriptname}"

}

Expand All @@ -66,7 +69,7 @@ function purge {

reponame=$1

repo_dir="${loc}/../repos/${reponame}/.git"
repo_dir="${repodir}/${reponame}/.git"

echo Removing ${reponame} from stored repos
rm -rf $repo_dir
Expand All @@ -77,10 +80,10 @@ function purge {
function list {

echo Listing all stored repos.
ls -R "${loc}/../repos"
ls -R "${repodir}"

echo Listing all active scripts.
ls "${loc}"
ls "${bindir}"

}

Expand Down
13 changes: 9 additions & 4 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@ $thispath = Split-Path -Parent $MyInvocation.MyCommand.Path
echo "Script running from $thispath"

$binpath = Join-Path -Path $thispath -ChildPath bin
$scriptpath = [Environment]::GetEnvironmentVariable('home', 'Machine')
$scriptpath = Join-Path -Path $scriptpath -ChildPath "/.git/script-bin"
$addpath = "$binpath;$scriptpath"

$oldpath = [Environment]::GetEnvironmentVariable('path', 'Machine')
if ($oldpath -like "*$binpath*") {
echo "Path already contains $binpath"
if ($oldpath -like "*$addpath*") {
echo "Path already contains $addpath"

} else {

echo "Adding $binpath to Path"
[Environment]::SetEnvironmentVariable('path', $oldpath + ';' + $binpath, 'Machine')
$newpath = "$oldpath;$addpath"

echo "Adding $addpath to Path"
[Environment]::SetEnvironmentVariable('path', $newpath, 'Machine')

$newpath = [Environment]::GetEnvironmentVariable('path', 'Machine')
echo "Path updated to be $newpath"
Expand Down
11 changes: 7 additions & 4 deletions uninstall.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,23 @@ $thispath = Split-Path -Parent $MyInvocation.MyCommand.Path
echo "Script running from $thispath"

$binpath = Join-Path -Path $thispath -ChildPath bin
$scriptpath = [Environment]::GetEnvironmentVariable('home', 'Machine')
$scriptpath = Join-Path -Path $scriptpath -ChildPath "/.git/script-bin"
$rempath = "$binpath;$scriptpath"

$oldpath = [Environment]::GetEnvironmentVariable('path', 'Machine')
if ($oldpath -like "*$binpath*") {
echo "Removing $binpath from Path"
if ($oldpath -like "*$rempath*") {
echo "Removing $rempath from Path"

$newpath = $oldpath.replace(";$binpath", '')
$newpath = $oldpath.replace(";$rempath", '')

[Environment]::SetEnvironmentVariable('path', $newpath, 'Machine')

$newpath = [Environment]::GetEnvironmentVariable('path', 'Machine')
echo "Path updated to be $newpath"

} else {
echo "Path doesn't contain $binpath"
echo "Path doesn't contain $rempath"

}

0 comments on commit c679a11

Please sign in to comment.