diff --git a/home/bashrc b/home/bashrc index c42beeb..a3fe472 100644 --- a/home/bashrc +++ b/home/bashrc @@ -28,10 +28,9 @@ ret_fail="$_title${Cfail}$_line1\n${Cfail}$_line2" PROMPT_COMMAND='[ $? = 0 ] && PS1=${ret_succ} || PS1=${ret_fail}' . ~/.-shrc +unset x # this doesn't work for all scripts at the moment, but ADDPATH "$HOME/sh" alias reload='cd; exec bash' - -unset x diff --git a/home/streamcrap b/home/streamcrap index 4d34b50..98059c1 100644 --- a/home/streamcrap +++ b/home/streamcrap @@ -39,6 +39,7 @@ _mpv_flags() { } watchstream1() { + pushd ~/play >/dev/null local url="$1" shift _mpv_flags @@ -49,6 +50,7 @@ watchstream1() { # bash syntax mpv $REPLY "$@" "$url" fi + popd >/dev/null } watchstream2() { diff --git a/install b/install index 312c27f..c83451f 100755 --- a/install +++ b/install @@ -1,10 +1,15 @@ #!/usr/bin/env bash + note() { echo -E "$@" } -die() { +warn() { echo -E "$@">&2 +} + +die() { + warn "$@" exit 1 } @@ -31,7 +36,7 @@ hardlink() { ln "$2" "$1" || die "couldn't hardlink $1" } -softlink() { +softlink_nix() { if [ -e "$1" ]; then if [ -h "$1" ]; then [ "$(readlink "$1")" == "$2" ] && return @@ -45,6 +50,49 @@ softlink() { ln -s "$2" "$1" || die "couldn't symlink $1" } +softlink_pseudo() { + [ -d "$2" ] || die "$1 is not a directory to softlink" + + if [ ! -d "$1" ]; then + mkdir "$1" || die "couldn't mkdir $1" + fi + + ls -A "$2" | while read -r; do + local d1="$1/$REPLY" + local d2="$2/$REPLY" + if [ -d "$d2" ]; then + softlink_pseudo "$d1" "$d2" + elif [ -f "$d2" ]; then + hardlink "$d1" "$d2" + else + die "i don't know how to pseudo-symlink $d2" + fi + done + + ls -A "$1" | while read -r; do + local d1="$1/$REPLY" + local d2="$2/$REPLY" + if [ -d "$d2" ]; then + : + elif [ ! "$d1" -ef "$d2" ]; then + [ "$d1" == ".vim/swp" ] && continue + [ "$d1" == ".vim/undo" ] && continue + [ "$d1" == ".vim/.netrwhist" ] && continue + warn "new destination file. consider manually moving it:" + warn "$d1" + fi + done +} + +softlink() { + if [ -n "$MSYSTEM" ]; then + # MSYS2 does not have nor emulate symbolic links. + softlink_pseudo "$@" + else + softlink_nix "$@" + fi +} + which readlink >/dev/null || exit 1 rc="$(readlink -f "$(dirname "$0")" )"