/r/commandline
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
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
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.
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
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:
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?
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?
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
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?
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.
git clone https://github.com/NewDawn0/youGotMail
Please be aware that I, the author, am not responsible for any misuse of this tool. Use it at your own risk.**
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
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.
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😁!
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:
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
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.
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.
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