Last active
July 27, 2020 22:19
-
-
Save Alligator/11e5bb01c12c8ac8b74824d54d1ee560 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
IF "%1" == "" ( | |
echo %cd% >> %userprofile%\_k | |
) ELSE ( | |
IF "%1" == "ls" ( | |
type %userprofile%\_k | |
exit /B | |
) | |
FOR /F "tokens=* USEBACKQ" %%F IN (`findstr "%1" "%userprofile%\_k"`) DO ( | |
cd %%F | |
exit /B | |
) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function k -a "path" | |
set k_file ~/.k | |
if test -z "$path" | |
echo (pwd) >> "$k_file" | |
else | |
switch "$path" | |
case "clean" | |
sort "$k_file" | uniq > "$k_file.tmp" && mv "$k_file.tmp" "$k_file" | |
case "rm" | |
sed -i -E "\#^"(pwd)"\$#d" "$k_file" | |
case "ls" | |
cat "$k_file" | |
case "*" | |
cd (grep -e "$path" "$k_file" | head -n 1) | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
k() { | |
if [ -z $1 ]; then | |
echo $PWD >> ~/.k | |
else | |
K=~/.k | |
case $1 in | |
clean) sort $K | uniq > ${K}.tmp && mv ${K}.tmp ${K};; | |
rm) sed -i -E "\#^${PWD}\$#d" ${K};; | |
ls) cat ${K};; | |
*) cd "$(grep -e "$1" ${K} | head -n 1)";; | |
esac | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment