/r/commandline

Photograph via snooOG

This is for anything regarding the command line, in any operating system. All questions (including dumb ones), tips, and links to interesting programs/console applications you've found or made yourself are welcome. Linux / BSD / OSX / Windows CLI and TUI apps or questions or comments, we're happy to take them all!

  -----------------------------

/ This is for anything
| regarding the command line, | | in any operating system. All | | questions (including dumb | | ones), tips, and interesting | | programs/console applications | | you've found or made yourself | | are welcome. Please read the | | rules, and you're welcome to | | flair your posts if you want |

\ to. /
\   ^__^
 \  (OO)\_______
    (__)\       )\/\
        ||----w |
        ||     ||

commandline@reddit ~ $ _


If you're asking for help, remember to help the community by stating what OS and version you're using, and if at all possible paste any commands you've tried and any errors or output that you've seen.


Related subreddits:

/r/commandline

97,804 Subscribers

2

How to setup warp like prompt?

I tried warp, and the prompts seems pretty cool. How do you achieve that without using warp? I assume it wouldn't be that hard and someone would've done it

3 Comments
2024/12/01
05:58 UTC

1

alternative to caffeine extension to ubuntu.

I need some help. What I want to know is if there is any terminal app, like caffeine extension of gnome, that I can install, that it's already on the ubuntu repository.

2 Comments
2024/11/30
19:24 UTC

23

Very Simple Command Line Journal

Hi, I've created an encrypted-journaling command-line application inspired by https://jrnl.sh It is just a single bash script for the app, and another script for the setup. I wanted something that was dead simple, and something that does not have too many dependencies.

The idea is to use existing tools to just start writing, and have the records automatically arranged in a specified folder.

Please check out the project here: https://github.com/nilz-bilz/cli-jrnl and let me know if there are any changes or improvements you guys would like to see. I haven't yet tested this on mac and other Unix systems, so it would be great to get some feedback on those platforms as well. Thanks

4 Comments
2024/11/30
12:04 UTC

4

is there a simpler cli tool for cropping images, or should I just stop being lazy and learn how to use imagemagick?

I want to take an image that is too wide to work as a wallpaper for my monitor (ie: a 32:9 wallpaper while I'm using my 21:9 monitor, or a 21:9 or 32:9 wallpaper while I'm using my laptop with no external monitor) and cut it into 10 equally spaced slices to show on my 10 workspaces, I'm hoping to get the same effect as on my android phone, where as I swipe to the right, it pans to the right on my background image.

A more concrete example, if I have a 5120x1440 image, and I'm using my 3440X1440 monitor, I want to create 10 horizontally cropped slices of the image. 1st going from 0-3440, 2nd going from 168-3608, 3rd going from 336-3773, etc incrementing by 168 each time (168 comes from (width of the original image - goal width)/number of workspaces, so (5120-3440)/10).

I can work out on my own how to script everthing else to work, what I need to figure out is how to make a script:

  1. check the resolution of whatever next wallpaper it picks
  2. if necessary create the image slices for each workspace

Is there a simpler tool to do that or should I just learn Imagemagick? I'm under the impression that imagemagick is in the same tier as ffmpeg as far as power and complexity, is this true or am I just avoiding it for nothing?

11 Comments
2024/11/29
22:51 UTC

0

Change local machine admin to other workstations in domain?

What would be the commands for that if I wanted to change lets say 40% of PC's local machine admin passwords? Only by using cmd. Or atleast to one person?

1 Comment
2024/11/29
14:47 UTC

81

elastop - HTOP for Elasticsearch

7 Comments
2024/11/29
05:42 UTC

23

yt-dlp supports most media urls include reddit

I learned today, that I could extract a reddit video using yt-dlp, which I normally use for Youtube content.

First, you need to review the codecs and figure out which video/audio streams you want to use.

 $ yt-dlp -F https://www.reddit.com/r/commandline/comments/1gzg8wu/docfd_900rc1_tui_multiline_fuzzy_document_finder/
[Reddit] Extracting URL: https://www.reddit.com/r/commandline/comments/1gzg8wu/docfd_900rc1_tui_multiline_fuzzy_document_finder/
[Reddit] 1gzg8wu: Downloading JSON metadata
[Reddit] 1gzg8wu: Downloading m3u8 information
[Reddit] 1gzg8wu: Downloading MPD manifest
[info] Available formats for 3wfqau4r113e1:
ID       EXT RESOLUTION FPS â   FILESIZE   TBR PROTO â VCODEC        VBR ACODEC     MORE INFO
ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ
dash-4   mp4 854x480        â ~  1.72MiB  335k https â avc1.4d401f  335k video only DASH video, mp4_dash
hls-272  mp4 854x480     30 â ~  1.39MiB  272k m3u8  â avc1.4D401F  272k video only
dash-5   mp4 1280x720       â ~  2.90MiB  566k https â avc1.4d401f  566k video only DASH video, mp4_dash
fallback mp4 1280x720       â â 12.30MiB 2400k https â h264        2400k video only DASH video, mp4_dash
hls-429  mp4 1280x720    30 â ~  2.20MiB  429k m3u8  â avc1.4D401F  429k video only

Then you extract the video. In this example, only the video codecs are available.

$ yt-dlp --format  dash-4 https://www.reddit.com/r/commandline/comments/1gzg8wu/docfd_900rc1_tui_multiline_fuzzy_document_finder/
[Reddit] Extracting URL: https://www.reddit.com/r/commandline/comments/1gzg8wu/docfd_900rc1_tui_multiline_fuzzy_document_finder/
[Reddit] 1gzg8wu: Downloading JSON metadata
[Reddit] 1gzg8wu: Downloading m3u8 information
[Reddit] 1gzg8wu: Downloading MPD manifest
[info] 3wfqau4r113e1: Downloading 1 format(s): dash-4
[download] Destination: Docfd 9.0.0-rc1ï¼ TUI multiline fuzzy document finder [3wfqau4r113e1].mp4
[download] 100% of    1.21MiB in 00:00:00 at 8.46MiB/s
-rw-r--r-- 1 XXX XXX 1267032 Nov 25 04:56 Docfd 9.0.0-rc1ï¼ TUI multiline fuzzy document finder [3wfqau4r113e1].mp4
3 Comments
2024/11/28
23:56 UTC

37

Bonsai Tree Generator for Bonsai-CLI (php port for cbonsai)

1 Comment
2024/11/28
22:32 UTC

6

Best command line tool to diff two texts without creating files?

I know I can vimdiff two files, but in the case it's two texts I can grab them from the clipboard, can I avoid creating files?

11 Comments
2024/11/28
21:19 UTC

0

🚀 [Project] youGotMail - Rust-Based Email Spammer (using Gmail Accounts)

Hey everyone!

I just finished building a simple but powerful email spammer called youGotMail in Rust. It allows you to send emails to a list of targets using your own Gmail accounts.

Key Features:

  • Rust-Based: Written in Rust for speed and efficiency.
  • Gmail Integration: Uses your Gmail account credentials to send emails.
  • Target List: You can provide a list of email addresses to which the mails will be sent.

Usage:

  • Clone the repo: git clone https://github.com/NewDawn0/youGotMail
  • Set up your Gmail account.
  • Modify the target email list in the config.
  • Run the program to send emails.

GitHub Repo:

👉 youGotMail GitHub

🚨 Legality Disclaimer:

Please be aware that I, the author, am not responsible for any misuse of this tool. Use it at your own risk.**

3 Comments
2024/11/28
14:40 UTC

0

Building a TCP Chat in Go

0 Comments
2024/11/28
11:26 UTC

34

bookbrowse - search books within your terminal

4 Comments
2024/11/28
08:57 UTC

1

Fetchmail crontab for flushing email

Hello.

Internally, I use fetchmail to consolidate my various domains into one master local server. I keep the last ~7 days on the remote server, until they are purged, so that I can still view urgent messages using webmail.

This is a basic crontab to use with fetchmail, when using the 'keep' directive.

MAILTO=""
*/5 * * * * cd $HOME; flock "/var/lock/fetchmail.$(whoami).lock" fetchmail
01  0 * * 0 cd $HOME; flock "/var/lock/fetchmail.$(whoami).lock" fetchmail --flush
2 Comments
2024/11/27
22:22 UTC

0

Easiest way to write some text into the google ecosystem, from the command line of a headless machine?

Hey hey,

I have some ubuntu machines and i use the google ecosystem since many years. Sometimes i think of things i want to remember, when i'm sitting at a terminal. What would be the easiest way to get a note on to the google ecosystem (or in worst case, some other cloud/server service) ?

I don't really need to read what is already there, but i would like to put something on to the stack, if you see what i mean. I can later review and edit/compile the notes, from a desktop machine.

NB: these are headless machines i am SSH:ing into.

20 Comments
2024/11/27
21:26 UTC

2

script writing help

r/bash deleted my post instantly, so here i post.

I run minecraft on my laptop while linking the datafile to an smb share.

So every time I want to play, i need to mount said share, and THEN open the mc app. I created a script that does that for me automatically, but i see it returning a strange message.

i'm pretty much a noob in writing code, but i try my best replicating what i watch on yt😅.

these are the two scripts i made

connectmc

#!/bin/bash
mkdir ~/Desktop/mclink ; mount_smbfs //user@server/Desktop ~/Desktop/mclink && echo Server Connected && open -a minecraft || echo Server Not Connected ; rmdir ~/Desktop/mclink 

ejectmc

#!/bin/bash
killall launcher ; sleep 5
umount ~/Desktop/mclink && rmdir ~/Desktop/mclink && echo Server Disconnected

so, after all that introduction.

my connection script returns both a success message and an error to rmdir

can anyone tell my why im getting this?

 $ connectmc 
Server Connected
rmdir: /Users/user/Desktop/mclink: Resource busy

ejectmc works fine btw😁!

16 Comments
2024/11/27
20:20 UTC

5

Problem with Zoxide: cd not adding folders

SOLVED. See below

I've installed zoxide as an apt package on a fresh ubuntu install, version 0.9.3, in Bash.
I have the required:

eval "$(zoxide init bash)"

In the .bashrc.
The question is the history is not building correctly on its own. An example:

https://preview.redd.it/qnjiaxpp0h3e1.png?width=779&format=png&auto=webp&s=cea946e0633e0da6c5d8e1c205bc8ff20ccc22db

I can add a directory manually with zoxide add, but it's very inconvenient, kind of messes up the main strength of the tool.

Any help will be much appreciated, thanks in advance

Solution
The issue was I was loading zoxide and then changing the PROMPT_COMMAND later in my .bashrc Moving it below solved it. Thanks to u/mattmc3

6 Comments
2024/11/27
16:28 UTC

34

🧩 x webtop - Run multiple Linux desktops in Docker, accessible via your browser

9 Comments
2024/11/27
10:32 UTC

65

I made this tool to turn any repo into a docker image

17 Comments
2024/11/27
05:15 UTC

24

What are some good cli screensavers (or similar) that I could use while running my server?

I am setting up this server as a code lab so my friends can use it. What can I run in the background as something cool to look at while I am at away?

I am currently using asciiquarium.

14 Comments
2024/11/26
07:18 UTC

11

[Yazi] Noob here. What went wrong here?

27 Comments
2024/11/25
18:49 UTC

10

plock - a tool for implementing very efficient low-latency pipe-based locking

LINK TO plock CODE ON GITHUB

plock is a bash function that implements locking very efficiently. It serves the same function as flock, though it isnt quite a drop-in replacement. However, plock is 5-10x faster (both in wall clock time and CPU time) than flock - on my system it can acquire and release a lock in a combined total of ~140 microseconds.

This makes it an ideal choice for situations where you need to acquire and release a lock repeatedly in rapid succession. An example of this might be having multiple process output to a file and using plock to ensure only 1 writes at a time (to ensure writes are atomic). One real-life example of this sort of usage is in my forkrun utility for running code in parallel where plock is used* to manage parallel i/o to a tmpfile containing inputs to run.

^(*ok, the plock function isnt actually used, but the methodology that plock uses is used. I figured out how to do pipe-based locking explicitly for use in forkrun. plock came afterwords with the intent of expanding the locking method that forkrun uses into a general-use locking function.)

##USAGE

Usage is very simple, and is very close to the flock $fd style of locking.

# source the plock function
. /path/to/plock.bash

# get lock
plock

# do stuff holding exclusive lock

# release lock
plock -u

Running plock will set a few variables in your shell: PLOCK_ID, PLOCK_FD and PLOCK_HAVELOCK. If you want to "join" into another existing lock, grab the PLOCK_ID from that process and then use

plock -p $PLOCK_ID

to share the lock with the process. This allows one to have a single lock shared between multiple processes, where each will automatically queue up and efficiently wait for the lock.

##HOW IT WORKS

When plock is first called, it opens an anonymous pipe at file desriptor $PLOCK_FD and writes a single newline to it.

exec {PLOCK_FD}<><(:)

If, instead, you are joining in an existing lock, plock searches procfs for the PLOCK_ID that you passed on the plock commandline. When it finds it (at /proc/<...>) it then instead runs

exec {PLOCK_FD}<>/proc/<...>

To aquire the lock, a process runs

read -r -n 1 -u $PLOCK_FD

which will consume the lone newline in the anonymous pipe's pipe buffer.

To release a lock, the process writes a newline back to the pipe

printf '\n' >&${PLOCK_FD}

When a process tries to aquire a lock that another process already has, there will be nothing in the pipe buffer and the read command will block. When the lock is released a newline is added to the pipe and the process waiting for the lock will aquire it instantly - no need for any sort of polling (i.e., repeatedly trying to aquire the lock, with a brief pause in between attempts). If multiple processes are waiting for the lock they will automatically be queued up. These aspects are all natively handled by the kernel's pipe/FIFO handling routines, and are handled very efficiently.

5 Comments
2024/11/25
14:13 UTC

45

Docfd 9.0.0-rc1: TUI multiline fuzzy document finder

14 Comments
2024/11/25
10:56 UTC

1

create a batch command line for offline disk

i have a problem to eject an external ssd. I can make it offline with some cmd commands, but i want to convert it as a batch file. Can someone converte this to batch ? :

- diskpart

- sel disk 1

- offline disk

5 Comments
2024/11/25
09:36 UTC

18

npx ctrader - Taipan! inspired trading simulation game

7 Comments
2024/11/24
17:43 UTC

Back To Top