Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ cd sd
setup/sd upgrade
```

_Note_: both the `install` and `upgrade` commands accept an optional 'dotfile'
argument that overrides where sd is pulled into the environment (defaults to
$HOME/.bash_profile).

#### Setup (Automatic)
For a one-off install, simply paste the following into your command line:
```bash
Expand Down
16 changes: 11 additions & 5 deletions setup/sd
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ sd_hook() {
}

modify_dotfile() {
if ! grep -q "define the sd function" "$HOME/.bash_profile" ; then
sd_hook >> $HOME/.bash_profile
local dotfile="${1:-$HOME/.bash_profile}"

if ! grep -q "define the sd function" "$dotfile" ; then
sd_hook >> "$dotfile"
else
echo
echo "*** Skipping addition of sd hook. ***"
echo "Previous installation found in $HOME/.bash_profile"
echo "Previous installation found in $dotfile"
echo "Please ensure something like the following is there:"
echo "--------------------------------------"
sd_hook
Expand All @@ -60,11 +62,15 @@ while [[ $# > 0 ]]; do
shift
case "x$arg" in
xinstall)
get_script && modify_dotfile && setup_complete
dotfile="$1"
shift
get_script && modify_dotfile "$dotfile" && setup_complete
;;
xupgrade)
dotfile="$1"
shift
pushd $repo_root &> /dev/null
symlink_sd && modify_dotfile && setup_complete
symlink_sd && modify_dotfile "$dotfile" && setup_complete
popd &> /dev/null
;;
xusage)
Expand Down