Skip to content

Instantly share code, notes, and snippets.

@tukkek
tukkek / text-resize.js
Last active October 13, 2025 14:24
Module to automatically-resize text-area elements.
// no-longer needed after Fire-fox implements textarea{field-sizing:content;}
function update(element){
let rows=element.value.split('\n').length
if(rows<1) rows=1
element.setAttribute('rows',rows)
}
export function resize(element){
update(element)
element.addEventListener('input',()=>update(element))
@tukkek
tukkek / minimal-prompt.md
Last active October 8, 2025 13:01
Minimalist BASH command-prompt.

Minimalist command-prompt for .bashrc-compatible terminals. Good for a clean-look or enabling more; smaller terminal-windows!

PS1_COLOR="\[$(tput bold)\]"
PS1_RESET="\[$(tput sgr0)\]"
PS1_STYLE=" ${PS1_COLOR}\W${PS1_RESET} "
# all terminals
PS1="$PS1_STYLE"
# some terminals
if [[ "$TERM_PROGRAM" == "vscode" ]]; then PS1="$PS1_STYLE"; fi
@tukkek
tukkek / run.js
Last active November 5, 2025 13:08
Runs a Deno system command.
/**
* Runs a system command.
*
* @param {string[]} flags An array of arguments, first one being the command name or path.
* @returns {number} The command's exit-status.
* @see https://docs.python.org/3/library/os.html#os.system
*/
async function run(flags){
let command=new Deno.Command(flags[0],{'args':flags.slice(1)})
let result=await command.output()
@tukkek
tukkek / selection-enhancer.js
Last active October 4, 2025 23:46
Selection-enhancer user-script
// ==UserScript==
// @name Selection enhancer.
// @namespace http://tampermonkey.net/
// @version 1.2
// @description Control-click selects and extends-selection.
// @author tukkek
// @match *://*/*
// @grant none
// ==/UserScript==
function expand(c){return c&&!/\s/.test(c)}
@tukkek
tukkek / history.sh
Last active October 4, 2025 23:46
Linux terminal history utility
#!/usr/bin/bash
# 1. Install Fuzzy Finder: apt-get install fzf
# 2. Place this script on your $PATH
# 3. Add to your ~/.bashrc file:
# alias "?=source history.sh"
# 4. Use the ? alias to search and select commands
cmd=`history|cut -c 8-|tac|fzf --reverse --scheme=history`
eval "$cmd"
history -s "$cmd"