Created
August 27, 2012 10:41
-
-
Save riywo/3487347 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_get_kamipo_bin() { | |
cat <<'EOF' | perl - "${BASH_SOURCE[0]}" | |
use strict; | |
use warnings; | |
use Cwd; | |
my $path = $ARGV[0] or die; | |
$path =~ s/^\.\/(.+)$/$1/; | |
$path = getcwd() . "/$path" if ($path !~ /^\//); | |
$path =~ s/^(.+)\/etc\/bashrc$/$1/; | |
print "$path/bin"; | |
EOF | |
} | |
_add_kamipo_path() { | |
local _bin_path=`_get_kamipo_bin` | |
cat << 'EOF' | perl - "$_bin_path" | |
use strict; | |
use warnings; | |
my $add_path = $ARGV[0] or die; | |
my @path = split /:/, $ENV{PATH}; | |
unless (grep { $_ eq $add_path } @path) { | |
push @path, $add_path; | |
} | |
print join(":", @path)."\n"; | |
EOF | |
} | |
export PATH=`_add_kamipo_path` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment