shcrt/shcrt

46 lines
940 B
Plaintext
Raw Normal View History

2019-09-06 16:58:07 +00:00
#!/bin/bash
export SHELL_LIBRARY_PATH="$SHELL_LIBRARY_PATH:./easybashgui/lib"
export PATH="$PATH:./easybashgui/src"
source easybashgui
function is_wsl {
grep -q Microsoft /proc/version
return $?
}
2019-09-06 17:51:56 +00:00
function wsl_win_var {
/mnt/c/Windows/System32/cmd.exe /C "echo $1"
}
2019-09-06 16:58:07 +00:00
function win_path_to_wsl {
2019-09-06 17:51:56 +00:00
if [[ "$1" != "" ]]; then
echo "$1" | sed -e 's|\\|/|g' -e 's|\(.*\):|/mnt/\L\1|'
else
cat - | sed -e 's|\\|/|g' -e 's|\(.*\):|/mnt/\L\1|'
fi
2019-09-06 16:58:07 +00:00
}
function scrt_session_path {
if is_wsl; then
2019-09-06 17:51:56 +00:00
appdata="$(wsl_win_var '%APPDATA%' | win_path_to_wsl)"
2019-09-06 16:58:07 +00:00
echo "$appdata/VanDyke/Config/Sessions"
else
echo "$HOME/.vandyke/SecureCRT/Config/Sessions"
fi
}
session_path="$(scrt_session_path)"
current_path=""
function scrt_cd {
2019-09-06 17:51:56 +00:00
if [ ! -d "$session_path/$current_path/$1" ]; then
2019-09-06 16:58:07 +00:00
return 1
fi
2019-09-06 17:51:56 +00:00
current_path="$(realpath -m --relative-to "$session_path" "$current_path/$1")"
2019-09-06 16:58:07 +00:00
}
function scrt_ls {
return 1;
}