feat: simple install script until archmgr completed
This commit is contained in:
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
node "$SCRIPT_DIR/util/auto-renamer/index.js" $@
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
extension="out"
|
||||
read -p "Pick extension to convert from: " extension
|
||||
outfolder="out"
|
||||
outext="mp4"
|
||||
read -p "Output folder: " outfolder
|
||||
read -p "Output extension: " outext
|
||||
|
||||
mkdir $outfolder
|
||||
for file in *.$extension; do
|
||||
ffmpeg -i "$file" "$outfolder/${file%.$extension}.$outext"
|
||||
echo "\n\n==> Conversion complete\n\n"
|
||||
done
|
||||
Executable
+75
@@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
connect() {
|
||||
read -sp $'Please enter your Encryption Password: ' encpass
|
||||
echo "
|
||||
==> Connecting"
|
||||
TOKEN=$(cat ~/.local/share/ethz-vpn-connect/ethzvpntoken.secret | openssl enc -aes-256-cbc -pbkdf2 -d -a -k $encpass)
|
||||
PASSWORD=$(cat ~/.local/share/ethz-vpn-connect/ethzvpnpass.secret | openssl enc -aes-256-cbc -pbkdf2 -d -a -k $encpass)
|
||||
USERNAME=$(cat ~/.local/share/ethz-vpn-connect/ethzvpnusername.txt)
|
||||
echo $PASSWORD | sudo openconnect -b -u $USERNAME@student-net.ethz.ch -g student-net --useragent=AnyConnect --no-external-auth --passwd-on-stdin --token-mode=totp --token-secret=sha1:base32:$TOKEN sslvpn.ethz.ch
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ' ==> Failed to connect <=='
|
||||
else
|
||||
echo ' ==> Connected <==
|
||||
'
|
||||
fi
|
||||
encpass=""
|
||||
PASSWORD=""
|
||||
TOKEN=""
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
sudo killall -v -SIGINT openconnect
|
||||
echo " ==> Disconnected"
|
||||
}
|
||||
|
||||
setup() {
|
||||
echo 'You are about to overwrite your secrets. Press ctrl + C to cancel.'
|
||||
read -p 'Please enter your ETHZ-Username: ' USERNAME
|
||||
read -sp 'Please choose and enter your Encryption Password (will be required when launching): ' encpass
|
||||
echo ""
|
||||
read -sp 'Please enter your ETHZ WLAN (= Radius) Password: ' PASSWORD
|
||||
echo ""
|
||||
read -sp 'Please enter your ETHZ OTP Secret: ' TOKEN
|
||||
echo ""
|
||||
if [[ -d ~/.local/share/ethz-vpn-connect ]]; then
|
||||
rm -rf ~/.local/share/ethz-vpn-connect
|
||||
fi
|
||||
mkdir ~/.local/share/ethz-vpn-connect
|
||||
echo $PASSWORD | openssl enc -aes-256-cbc -pbkdf2 -a -k $encpass >~/.local/share/ethz-vpn-connect/ethzvpnpass.secret
|
||||
echo $TOKEN | openssl enc -aes-256-cbc -pbkdf2 -a -k $encpass >~/.local/share/ethz-vpn-connect/ethzvpntoken.secret
|
||||
echo $USERNAME >~/.local/share/ethz-vpn-connect/ethzvpnusername.txt
|
||||
encpass=""
|
||||
PASSWORD=""
|
||||
TOKEN=""
|
||||
if [ $? -ne 0 ]; then
|
||||
echo ' ==> Failed to set secrets <=='
|
||||
else
|
||||
echo ' ==> Secrets set <==\n'
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'connect')
|
||||
connect
|
||||
;;
|
||||
c)
|
||||
connect
|
||||
;;
|
||||
'disconnect')
|
||||
disconnect
|
||||
;;
|
||||
d)
|
||||
disconnect
|
||||
;;
|
||||
dc)
|
||||
disconnect
|
||||
;;
|
||||
setup)
|
||||
setup
|
||||
;;
|
||||
*)
|
||||
echo -e 'Usage: ethz-vpn [Option] \n [Option]: \n connect, c: Connect VPN \n disconnect, d, dc: Disconnect VPN \n setup: set secrets and eth-Username.\n'
|
||||
;;
|
||||
esac
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "Word count is $(pdftotext $1 - | tr -d '.' | wc -w)"
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
cp "$SCRIPT_DIR/../linters/clang-format" ./.clang-format
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
cp "$SCRIPT_DIR/../linters/eslint.config.mjs" .
|
||||
|
||||
npm i --save-dev @eslint/js typescript-eslint @stylistic/eslint-plugin eslint-plugin-vue globals
|
||||
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
SCRIPT_DIR=$(dirname "$0")
|
||||
|
||||
cp "$SCRIPT_DIR/../linters/indentconfig.yaml" ./.latexindent.yaml
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
is_docked=$(cat ~/.config/janishutz/docked)
|
||||
if [ $is_docked == "y" ]; then
|
||||
echo "n" >~/.config/janishutz/docked
|
||||
else
|
||||
echo "y" >~/.config/janishutz/docked
|
||||
fi
|
||||
|
||||
hyprctl reload
|
||||
|
||||
echo "Switched to docked mode"
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
enabled=$(hyprctl getoption input:kb_options | grep "caps:swapescape")
|
||||
if [[ $enabled == "" ]]; then
|
||||
hyprctl keyword input:kb_options "caps:swapescape"
|
||||
notify-send "Swapescape enabled"
|
||||
else
|
||||
hyprctl keyword input:kb_options ""
|
||||
notify-send "Swapescape disabled"
|
||||
fi
|
||||
Executable
+5
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd ~/projects/nvim/
|
||||
git pull
|
||||
./nvim-install.sh
|
||||
@@ -0,0 +1,238 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { argv } = require('process');
|
||||
|
||||
const config = {
|
||||
// replace character of key with value, any character, apart from ['.', '_', '-', ' ']
|
||||
'replace': {
|
||||
'ä': 'ae',
|
||||
'ö': 'oe',
|
||||
'ü': 'ue',
|
||||
',': '-',
|
||||
'&': 'And',
|
||||
},
|
||||
'rules': {
|
||||
'underscore-before-and-after-number': true, // Will not do trailing or leading for filename
|
||||
'enforce-leading-zero': true, // adds a leading zero to any number below 10
|
||||
'camel-case-rules': {
|
||||
'enforce-snake-case-for-filetypes': ['py'], // using underscores
|
||||
'enforce-kebab-case-for-filetypes': ['css', 'html', 'scss', 'tex'], // using hyphens
|
||||
},
|
||||
'file-start-letter': 'lower', // lower, upper, unchanged
|
||||
'directory-start-letter': 'upper', // lower, upper, unchanged
|
||||
'replace-dots-with': '', // will not replace as leading character to not break dotfiles
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively find all files with extension in a directory
|
||||
* @param {string} dir The directory to search. Either absolute or relative path
|
||||
* @param {string} extension The file extension to look for
|
||||
* @param {boolean} cleanup If helper files (like .DS_STORE and Windows helpers should be auto-deleted)
|
||||
* @param {string[]} ignoreList A list of filenames or directories to ignore
|
||||
* @returns {{ files: string, directories: string }} returns a list of html files with their full path
|
||||
*/
|
||||
const treeWalker = (dir, extension, cleanup, ignoreList) => {
|
||||
const ls = fs.readdirSync(dir);
|
||||
const fileList = [];
|
||||
const dirList = [];
|
||||
for (let file in ls) {
|
||||
if (fs.statSync(path.join(dir, ls[file])).isDirectory()) {
|
||||
// Filter ignored directories
|
||||
if (ignoreList === undefined || !ignoreList.includes(ls[file])) {
|
||||
const newData = treeWalker(path.join(dir, ls[file]), extension, ignoreList);
|
||||
const newFiles = newData.files;
|
||||
dirList.push( path.join( dir, ls[ file ] ) );
|
||||
for (let dir = 0; dir < newData.directories.length; dir++) {
|
||||
dirList.push( newData.directories[dir] );
|
||||
}
|
||||
for (let file = 0; file < newFiles.length; file++) {
|
||||
fileList.push(newFiles[file]);
|
||||
}
|
||||
}
|
||||
} else if (extension == '*' || ls[file].includes(extension)) {
|
||||
if (ignoreList === undefined || !ignoreList.includes(ls[file])) {
|
||||
fileList.push(path.join(dir, ls[file]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { 'files': fileList, 'directories': dirList };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} filename The filename to fix according to the rules
|
||||
* @returns {string} the fixed filename
|
||||
*/
|
||||
const fixName = ( fn, ft ) => {
|
||||
let out = '';
|
||||
const enforceSnake = config.rules['camel-case-rules']['enforce-snake-case-for-filetypes'].includes( ft );
|
||||
const enforceKebab = config.rules['camel-case-rules']['enforce-kebab-case-for-filetypes'].includes( ft );
|
||||
const isDir = ft === 'directory';
|
||||
const startLetter = isDir ? config.rules['directory-start-letter'] : config.rules['file-start-letter'];
|
||||
let nextUpperCase = false;
|
||||
|
||||
for ( let i = 0; i < fn.length; i++ ) {
|
||||
const c = fn[i];
|
||||
|
||||
if ( c == '.' ) {
|
||||
// Rule: Removed after number, allowed elsewhere
|
||||
if ( i > 0 && /[0-9]/.test( fn[ i - 1 ] ) ) {
|
||||
out += config.rules[ 'replace-dots-with' ];
|
||||
} else {
|
||||
out += '.';
|
||||
}
|
||||
} else if ( /[A-Z]/.test( c ) ) {
|
||||
// If we reach a capital letter and enforce either kebab-case or snake_case, we can assume that this is the start of a CamelCase word
|
||||
if ( enforceKebab ) {
|
||||
out += '-' + c.toLowerCase();
|
||||
} else if ( enforceSnake ) {
|
||||
out += '_' + c.toLowerCase();
|
||||
} else {
|
||||
nextUpperCase = false;
|
||||
if ( i == 0 && startLetter === 'lower' ) {
|
||||
out += c.toLowerCase();
|
||||
} else {
|
||||
out += c;
|
||||
}
|
||||
}
|
||||
} else if ( c == ' ' ) {
|
||||
// We always replace spaces, the question is just to what
|
||||
if ( enforceKebab ) {
|
||||
out += '-';
|
||||
} else if ( enforceSnake ) {
|
||||
out += '_';
|
||||
} else {
|
||||
nextUpperCase = true;
|
||||
}
|
||||
} else if ( c == '_' ) {
|
||||
// If we are not enforcing snake_case, then replace it
|
||||
if ( !enforceSnake ) {
|
||||
if ( needsUnderscore( i, fn ) ) {
|
||||
out += '_';
|
||||
} else if ( enforceKebab ) {
|
||||
out += '-';
|
||||
} else {
|
||||
nextUpperCase = true;
|
||||
}
|
||||
} else {
|
||||
out += '_'
|
||||
}
|
||||
} else if ( c == '-' ) {
|
||||
// If we are not enforcing kebab-case
|
||||
if ( !enforceKebab ) {
|
||||
if ( enforceSnake ) {
|
||||
out += '_';
|
||||
} else {
|
||||
nextUpperCase = true;
|
||||
}
|
||||
} else {
|
||||
out += '-'
|
||||
}
|
||||
} else {
|
||||
let curr = config.replace[ c ] === undefined ? c : config.replace[ c ];
|
||||
if ( config.rules[ 'underscore-before-and-after-number' ] || config.rules['enforce-leading-zero'] ) {
|
||||
if ( /[0-9]/.test( c ) ) {
|
||||
if ( i < fn.length - 1 ) {
|
||||
if ( config.rules['enforce-leading-zero'] ) {
|
||||
const prevIsNumber = i > 0 && /[0-9]/.test( fn[i - 1] );
|
||||
const nextIsNumber = /[0-9]/.test( fn[i + 1] );
|
||||
if ( !nextIsNumber && ( i == 0|| !prevIsNumber ) ) {
|
||||
curr = '0' + curr;
|
||||
}
|
||||
}
|
||||
|
||||
if ( config.rules['underscore-before-and-after-number'] ) {
|
||||
if ( !( /[0-9]/.test( fn[ i + 1 ] ) ) && fn[ i + 1 ] != '_' ) {
|
||||
curr += '_';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( config.rules['enforce-leading-zero'] && ( i > 0 && !( /[0-9]/.test( fn[i - 1] ) ) ) ) {
|
||||
curr = '0' + curr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( config.rules['underscore-before-and-after-number'] && /[0-9]/.test( fn[ i + 1 ] ) ) {
|
||||
curr += '_';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( nextUpperCase || ( i == 0 && startLetter === 'upper' ) ) {
|
||||
nextUpperCase = false;
|
||||
out += curr.toUpperCase();
|
||||
} else {
|
||||
if ( i == 0 && startLetter === 'upper' ) {
|
||||
out += curr.toUpperCase();
|
||||
} else {
|
||||
out += curr.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const needsUnderscore = ( i, fn ) => {
|
||||
return ( i > 0 && /[0-9]/.test( fn[ i - 1 ] ) ) || ( i < fn - 1 && /[0-9]/.test( fn[ i + 1 ] ) )
|
||||
}
|
||||
|
||||
const separateDirAndFileAndFiletype = ( filename ) => {
|
||||
const loc = filename.lastIndexOf( '/' ) + 1;
|
||||
let ftl = filename.lastIndexOf( '.' ) + 1;
|
||||
let fn = filename.substring( loc, ftl - 1 );
|
||||
let ft = filename.substring( ftl );
|
||||
if ( fs.statSync( filename ).isDirectory() ) {
|
||||
ftl = filename.length;
|
||||
fn = filename.substring( loc );
|
||||
ft = 'directory';
|
||||
|
||||
}
|
||||
const dir = filename.slice( 0, loc - 1 );
|
||||
return { 'filename': fn, 'dir': dir, 'filetype': ft };
|
||||
}
|
||||
|
||||
const fixDirName = ( directory, top ) => {
|
||||
if ( directory === top ) {
|
||||
return top;
|
||||
}
|
||||
|
||||
const f = separateDirAndFileAndFiletype( directory );
|
||||
return fixDirName( f.dir, top ) + '/' + fixName( f.filename, f.filetype );
|
||||
}
|
||||
|
||||
if (argv[2] == '-h') {
|
||||
console.log('auto-renamer [directory]\n\n=> Recursively rename files in directory');
|
||||
} else if (argv[2] == '-v') {
|
||||
console.log('auto-renamer version 1.0.0, developed by Janis Hutz (development@janishutz.com)');
|
||||
} else {
|
||||
// Recursively add all files in the directory
|
||||
const fp = path.resolve( argv[2] );
|
||||
const list = treeWalker(fp, '*', ['.git', '@girs']);
|
||||
const files = list.files;
|
||||
const directories = list.directories;
|
||||
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
const f = separateDirAndFileAndFiletype( file );
|
||||
let fixedFile = fixName( f.filename, f.filetype );
|
||||
|
||||
// Rename
|
||||
const fixedPath = f.dir + '/' + fixedFile + '.' + f.filetype;
|
||||
console.log( file + ' -> ' + fixedPath );
|
||||
fs.renameSync( file, fixedPath );
|
||||
}
|
||||
|
||||
// Fix directory names after file names. Sort array by decending length
|
||||
directories.sort( ( a, b ) => {
|
||||
return b.length - a.length;
|
||||
} );
|
||||
|
||||
// separate directories up until we reach the path of dir started in
|
||||
for (let i = 0; i < directories.length; i++) {
|
||||
const dir = directories[i];
|
||||
const fixed = fixDirName( dir, fp );
|
||||
console.log( dir + ' -> ' + fixed );
|
||||
fs.renameSync( dir, fixDirName( dir, fp ) );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user