Skip to content

Instantly share code, notes, and snippets.

View BeyondMagic's full-sized avatar
🐟
wown

João V. Farias BeyondMagic

🐟
wown
View GitHub Profile
@BeyondMagic
BeyondMagic / tuxi-dmenu-panel-script.md
Last active May 30, 2023 00:39
tuxi dmenu script for panel (polybar, i3bar, xfce4-panel, etc)

(https://github.com/Bugswriter/tuxi) is a suckless shell script that get you information.

  1. Create two scripts file.
  2. The first will have the following bash script. This is to load the output of tuxi. Let's call it loadtuxi.sh
#!/bin/bash
O="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
cat "$O/lecture.tuxi" | tr '\n' ' ' | cut -c 1-50
# You can adjust the cut to how many characters you want...
# Or remove the tr to get only the first line.
@BeyondMagic
BeyondMagic / center.js
Last active May 30, 2023 00:39
Center a string (colums) in Node.js Terminal with a simple and fast function.
// center in terminal size (colums only yet) //
const center = (str, instead, only = false, letter = ' ') => {
// str = string to center // String //
// instead = instead of using process.stdoud use this // Array //
// only = only add space (+= ' ') // Boolean //
// letter = instead of using space use this // String with one letter //
// need always a string
if (!str) return '';
@BeyondMagic
BeyondMagic / truelength.js
Last active January 19, 2024 12:52
Get the real length of a string with hex codes. Useful when looping through a string.
// get true length of a a string with colors
// this is necessary since javascript counts everything in the string
// which is not good when you are looping a string
// mainly when you are using it to make it even with the terminal size
// you can pass it to String.prototype and remove the test of string
const length = str => {
//always string
if (!str || typeof str !== 'string')
return 0;