1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2025-02-05 07:43:22 -08:00

add pseudo-softlinks for msys2 and stuff

This commit is contained in:
Connor Olding 2016-11-01 15:22:38 -07:00
parent e7690162cb
commit 48d7bb9f1d
3 changed files with 53 additions and 4 deletions

View file

@ -28,10 +28,9 @@ ret_fail="$_title${Cfail}$_line1\n${Cfail}$_line2"
PROMPT_COMMAND='[ $? = 0 ] && PS1=${ret_succ} || PS1=${ret_fail}' PROMPT_COMMAND='[ $? = 0 ] && PS1=${ret_succ} || PS1=${ret_fail}'
. ~/.-shrc . ~/.-shrc
unset x
# this doesn't work for all scripts at the moment, but # this doesn't work for all scripts at the moment, but
ADDPATH "$HOME/sh" ADDPATH "$HOME/sh"
alias reload='cd; exec bash' alias reload='cd; exec bash'
unset x

View file

@ -39,6 +39,7 @@ _mpv_flags() {
} }
watchstream1() { watchstream1() {
pushd ~/play >/dev/null
local url="$1" local url="$1"
shift shift
_mpv_flags _mpv_flags
@ -49,6 +50,7 @@ watchstream1() {
# bash syntax # bash syntax
mpv $REPLY "$@" "$url" mpv $REPLY "$@" "$url"
fi fi
popd >/dev/null
} }
watchstream2() { watchstream2() {

52
install
View file

@ -1,10 +1,15 @@
#!/usr/bin/env bash #!/usr/bin/env bash
note() { note() {
echo -E "$@" echo -E "$@"
} }
die() { warn() {
echo -E "$@">&2 echo -E "$@">&2
}
die() {
warn "$@"
exit 1 exit 1
} }
@ -31,7 +36,7 @@ hardlink() {
ln "$2" "$1" || die "couldn't hardlink $1" ln "$2" "$1" || die "couldn't hardlink $1"
} }
softlink() { softlink_nix() {
if [ -e "$1" ]; then if [ -e "$1" ]; then
if [ -h "$1" ]; then if [ -h "$1" ]; then
[ "$(readlink "$1")" == "$2" ] && return [ "$(readlink "$1")" == "$2" ] && return
@ -45,6 +50,49 @@ softlink() {
ln -s "$2" "$1" || die "couldn't symlink $1" 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 which readlink >/dev/null || exit 1
rc="$(readlink -f "$(dirname "$0")" )" rc="$(readlink -f "$(dirname "$0")" )"