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:
parent
e7690162cb
commit
48d7bb9f1d
3 changed files with 53 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
52
install
52
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")" )"
|
||||
|
|
Loading…
Add table
Reference in a new issue