huehuehuehuehue
This commit is contained in:
parent
9874c9858c
commit
71e7cf6eaf
23
scripts/archive
Executable file
23
scripts/archive
Executable file
|
@ -0,0 +1,23 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description="Place a folder in ~/Documents in ~/Documents/Archive and symlink it")
|
||||||
|
parser.add_argument('dir', metavar='DIRECTORY', type=str, help="The directory to archive")
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
source = os.path.realpath(args.dir)
|
||||||
|
assert(os.path.isdir(source)), source + " must be a directory"
|
||||||
|
|
||||||
|
# Finding directories
|
||||||
|
assert('HOME' in os.environ), "Home directory unknown"
|
||||||
|
docs = os.path.realpath(os.path.join(os.environ['HOME'], 'Documents'))
|
||||||
|
assert(os.path.isdir(docs)), "Documents folder not found"
|
||||||
|
arcs = os.path.join(docs, 'Archives')
|
||||||
|
assert(os.path.isdir(arcs)), "Archives folder not found"
|
||||||
|
|
||||||
|
assert(source.startswith(docs)), "Directory is not in the document folder"
|
||||||
|
assert(not source.startswith(arcs)), "Directory is already in the archive folder"
|
||||||
|
|
||||||
|
|
70
scripts/gitghost
Executable file
70
scripts/gitghost
Executable file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/usr/bin/bash
|
||||||
|
|
||||||
|
# Replace git folders with a placeholder containing the remote and the commit
|
||||||
|
|
||||||
|
function prompt { # text
|
||||||
|
while true; do
|
||||||
|
read -p "$1 [yn] " yn
|
||||||
|
case $yn in
|
||||||
|
[Yy]* ) return 1;;
|
||||||
|
[Nn]* ) return 0;;
|
||||||
|
* ) echo "Please answer yes or no.";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "$#" == 0 || "$#" > 2 ]]
|
||||||
|
then
|
||||||
|
echo "Usage: $0 gitfolder [-y]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
folder="$(echo "$1" | sed 's/\/*$//')"
|
||||||
|
if [ "$2" == "-y" ]
|
||||||
|
then
|
||||||
|
donotask=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$folder/.git" ]
|
||||||
|
then
|
||||||
|
echo "$folder is not a git repository"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$(git -C "$folder" diff)" ]
|
||||||
|
then
|
||||||
|
echo "WARNING: There are unstaged change. Those will be discarded if you continue."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Be sure that every commit in the repository is backed up somewhere else, since those will be discarded."
|
||||||
|
|
||||||
|
TMPFILE=$(mktemp)
|
||||||
|
|
||||||
|
(echo "[gitplaceholder]"
|
||||||
|
echo "lastcommit=$(git log --format="%H" -n 1)"
|
||||||
|
echo
|
||||||
|
echo "[remote]"
|
||||||
|
git -C "$folder" remote -v
|
||||||
|
echo
|
||||||
|
echo "[branch]"
|
||||||
|
git -C "$folder" branch -v
|
||||||
|
echo
|
||||||
|
echo "[diff]"
|
||||||
|
git -C "$folder" diff -v) > $TMPFILE 2> /dev/null
|
||||||
|
|
||||||
|
if [ ! $donotask ]
|
||||||
|
then
|
||||||
|
less $TMPFILE
|
||||||
|
echo
|
||||||
|
echo "This will be written in place of $folder."
|
||||||
|
prompt "Do you want to continue ?"
|
||||||
|
if [ "$?" == 0 ]
|
||||||
|
then
|
||||||
|
echo "Canceled"
|
||||||
|
rm $TMPFILE
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Dummying..."
|
||||||
|
rm -rf "$folder"
|
||||||
|
mv $TMPFILE $folder
|
|
@ -316,6 +316,10 @@ if [ $EXTRA == 1 ]; then
|
||||||
if [ $ARCH == 1 ]; then
|
if [ $ARCH == 1 ]; then
|
||||||
inst jq
|
inst jq
|
||||||
altInst pdftk translate-shell git-lfs js-beautify insect visidata-git
|
altInst pdftk translate-shell git-lfs js-beautify insect visidata-git
|
||||||
|
else
|
||||||
|
# translate-shell
|
||||||
|
curl -L git.io/trans > ~/.bin/trans
|
||||||
|
chmod +x ~/.bin/trans
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Extra GUI
|
# Extra GUI
|
||||||
|
|
|
@ -37,6 +37,8 @@ if (argv.t) {
|
||||||
template = fs.readFileSync(argv.t, "utf8");
|
template = fs.readFileSync(argv.t, "utf8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var latex = true;
|
||||||
|
// TODO Arg
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
|
||||||
|
@ -74,7 +76,9 @@ for (lang in extraLangages) {
|
||||||
var renderer = new marked.Renderer();
|
var renderer = new marked.Renderer();
|
||||||
marked.setOptions({
|
marked.setOptions({
|
||||||
highlight: function(code, lang) {
|
highlight: function(code, lang) {
|
||||||
if (highlight.getLanguage(lang)) {
|
if (lang == 'raw') {
|
||||||
|
return code;
|
||||||
|
} else if (highlight.getLanguage(lang)) {
|
||||||
return highlight.highlight(lang, code).value;
|
return highlight.highlight(lang, code).value;
|
||||||
} else {
|
} else {
|
||||||
// if (extraLangages[lang]) {
|
// if (extraLangages[lang]) {
|
||||||
|
@ -93,17 +97,27 @@ marked.setOptions({
|
||||||
markdownString = fs.readFileSync(argv.i, "utf8");
|
markdownString = fs.readFileSync(argv.i, "utf8");
|
||||||
|
|
||||||
// TeX
|
// TeX
|
||||||
|
if (latex) {
|
||||||
markdownString = markdownString.replace(/\\\$/g, '$')
|
markdownString = markdownString.replace(/\\\$/g, '$')
|
||||||
markdownString = markdownString.replace(/\$\$([\s\S]+)\$\$/gm, function(glob, formula) {
|
markdownString = markdownString.replace(/\$\$([\s\S]+)\$\$/gm, function(glob, formula) {
|
||||||
return katex.renderToString(formula, {displayMode: true});
|
return katex.renderToString(formula, {
|
||||||
|
displayMode: true
|
||||||
|
});
|
||||||
});
|
});
|
||||||
markdownString = markdownString.replace(/\$([^$]+)\$/g, function(glob, formula) {
|
markdownString = markdownString.replace(/\$([^$]+)\$/g, function(glob, formula) {
|
||||||
return katex.renderToString(formula, {displayMode: false});
|
return katex.renderToString(formula, {
|
||||||
|
displayMode: false
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Conversion
|
// Conversion
|
||||||
htmlString = marked(markdownString, {renderer: renderer});
|
htmlString = marked(markdownString, {
|
||||||
fullHtmlString = template.replace('%BODY%', htmlString);
|
renderer: renderer
|
||||||
|
});
|
||||||
|
// fullHtmlString = htmlString;
|
||||||
|
fullHtmlString = template.replace('%BODY%', () => { return htmlString });
|
||||||
|
|
||||||
|
|
||||||
// Saving
|
// Saving
|
||||||
if (argv.o == '/dev/stdout') {
|
if (argv.o == '/dev/stdout') {
|
||||||
|
|
Loading…
Reference in a new issue