Share a script/alias you use a lot
from als@lemmy.blahaj.zone to linux@lemmy.ml on 23 Jun 08:12
https://lemmy.blahaj.zone/post/27914971
from als@lemmy.blahaj.zone to linux@lemmy.ml on 23 Jun 08:12
https://lemmy.blahaj.zone/post/27914971
A while ago I made a tiny function in my ~/.zshrc to download a video from the link in my clipboard. I use this nearly every day to share videos with people without forcing them to watch it on whatever site I found it. What’s a script/alias that you use a lot?
# Download clipboard to tmp with yt-dlp tmpv() { cd /tmp/ && yt-dlp "$(wl-paste)" }
threaded - newest
Not on mine tho
Gonna run right out and try this on all the servers! Thanks!
With how many new Linux users we get recently, I don’t like this joke at all without a disclaimer. Yes yes, its your own fault if you execute commands without knowing what it does. But that should not punish someone by deleting every important personal file on the system.
In case any reader don’t know,
rm
is a command to delete files and with the optionrm -r
everything recursively will be searched and deleted on the filesystem. Option-f
(here bundled together as-rf
) will never prompt for any non existing file. The/
here means start from the root directory of you system, which in combination with the recursive option will search down everything, home folder included, and find every file. Normally this is protected todo, but the extra option–no-preserve-root
makes sure this command is run with the root/
path.Haha I know its funny. Until someone loses data. Jokes like these are harmful in my opinion.
I agree. This thread is for actual advice.
rm -rf /
belongs in a joke thread.So, as a beginner, you would know how to make an alias but not the most famous Linux joke ever ? Explain your mental gymnastics.
You don’t need to understand a command in order to copy paste an alias or Bash function. Especially newcomers could tend to do it, without knowing what the command actually does. We are also in a posting with helpful commands, so its double harmful. And you doubling down without adding any sort of disclaimer shows you don’t care.
I usually set up an alias or script to update everything on my system. For example, on Ubuntu, I would do this:
alias sysup=‘snap refresh && apt update && apt upgrade’
And on Arch, I do this:
alias sysup =‘flatpak update && paru’
Funny enough you’d need to use
sudo
to run this on Ubuntu, but not in the Arch example because paru being neatCan I introduce you to Topgrade? ;)
Why install another bit of software when a simple alias will do the job nicely?
For me, I find it handy because it catches a bunch of stuff I always forget, like updating Docker containers. Also if you have Am installed it’ll even update your Appimages.
I consider updating my docker containers part of updating my dev environment, which is on a different schedule to my system updates. I use a function for updating them.
Because:
Of course if you’re a minimalist, then you probably don’t have that much stuff that needs upgrading in the first place. For me personally I have
deb-get
,uv
,cargo
, andflatpak
, to name a few; the alias was getting longer and longer until I was able to remove it completely by switching to Topgrade.I use Topgrade, but I use the alias
update
to run it lolHere is mine for EndeavourOS (based on Arch, BTW):
And related for uninstalling something:
I have a similar update function here. With a bit more bells and whistles: github.com/dannyfritz/dotfiles/…/config.fish#L123
For doing stuff in a directory, I use a replacement for
cd
command.For aliases:
I also have various small scripts and functions:
a
for package management (thinkapt
but has simplified arguments which makes it faster to use in usual cases),e
for opening file in Emacs,g
forgit
,s
forsudo
.And here’s
,
:Similar to yours OP I copy many URLs and then run my script that takes the number of URLs I copied eg 5,and downloads them with
yt-dlp
and GNUparallel
to~/Videos
I use CopyQ to hold the clipboard history.
For docker: I’m not following best practices. I have a giant docker compose file for my entire home lab, this is how I update things:
For me it’s pretty basic. It’s mostly aliases for nix related commands, like rebuild-switch, updating, garbage collecting, because those nix commands are pretty lenghty, especially with having to point to your flake and everything. I’m thinking of maybe adding an alias for cyanrip (cli cd ripper), because i recently ripped my entire cd collection, but going forward if i buy another cd every now and then, i’ll probably end up forgetting about which flags i used.
Here are probably the most useful ones. I prefer for
rm
to be interactive so I don't accidentally delete something important and formkdir
to create a parent directory if necessary.This extract function (which I didn't make myself, I got it from when I was using nakeDeb) has been pretty useful too.
I have a similar docker/podman alias, except I pull first. This greatly reduces downtime between
down
andup
, which is nice for critical services.Yeah, that makes sense. I don't have anything critical; just nginx, a book server, a recipe collection, and some other small stuff.
I’ll share 3:
i also have the chmod one, but mine is named just x:
I also have the
yt-dlp “$(wl-paste)”
one, but its build around a custom script. So sharing it here makes no sense. Its funny how often we do same thing in different ways (extracting or creating archives in example). Often aliases get development into function and then they turn into scripts. For some of the more simple aliases, here a selection:To answer your question realistically I did
history | sed “s/.* //” | sort | uniq -c | sort -n
which returned as first non standard command
lr
which from mygrep lr ~/.bashrc
isalias lr=“ls -lrth”
A few days ago I posted a one-liner to do the same thing too. It will resolve aliases from your history and expand program paths to its fullpath. I thought you might be interested: beehaw.org/post/20584479
Thanks for sharing, always nice to learn alternative ways to do so!
I replaced rm with trash-put, just in case I realize I need some files that I removed down the line.
Official author don’t recommend it due to different semantics. But honestly for my own personal use case its fine for me.
Also I like to alias xclip:
Little tip: In case you need to use
rm
directly, even with the alias in effect, you can put a backslah in front of the command to use its original meaning:\rm filename
oooh so does that apply to any command/user binary on the system?
I’m not sure what you mean with the question. If you have any alias like
alias rm=‘ls -l’
in your .bashrc in example, then you cannot use the original commandrm
anymore, as it is aliased to something else. I’m speaking about the terminal, when you enter the command. However, if you put a backslash in front of it like\rm
in the terminal, then the alias for it is ignored and the original command is executed instead.Edit: Made a more clear alias example.
Oh ty ty that answers my question! I am fairly new to being a poweruser on linux so I may have worded that wrong XD
I don’t recommend that either. If you get used to that ‘rm’ doesn’t actually remove files and then your alias is missing for whatever reason it’ll bite you in the rear at some point. And obviously the same hazard goes with a ton of other commands too.
Agree, comes down to risk acceptance honestly.
I accepted the risk that comes with it. Same with some other aliases on equally hazardous commands.
it’s somewhat vibe coded but the one i probably use the most is this one to swap between speakers and headset. the device name to look for is just put directly in there, it’d take some adjustment to run it on different machines. this is in my .bashrc:
generally i try not to use too many custom things because for work i regularly work on all kinds of different servers and i’ve just been too lazy to set up some solution to keep it all in sync. someday…
My desktop text editor has an autosave feature, but it only works after you’ve manually saved the file. All I wanted is something like the notes app on my phone, where I can jot down random thoughts without worrying about naming a new file. So here’s the script behind my text editor shortcut, which creates a new text file in ~/.drafts, names it with the current date, adds a suffix if the file already exists, and finally opens the editor:
Ooooh tmpv is a smart name for your little tool. I may steal it lol
Please do!
I have started my daily drawing journey which i still am bad at it. To create a new .kra files files every day I use this
Monika from ddlc? :O
JUST MONIKA
Best waifu of history <3
I often want to know the status code of a
curl
request, but I don’t want that extra information to mess with the response body that it prints to stdout.What to do?
Render an image instead, of course!
<img alt="" src="https://midwest.social/pictrs/image/0f68f5d0-81a0-485e-baf8-4134878b14ad.png">
curlcat
takes the same params ascurl
, but it uses iTerm2’simgcat
tool to draw an “HTTP Cat” of the status code.It even sends the image to stderr instead of stdout, so you can still pipe
curlcat
tojq
or something.Note: This is macOS-specific, as written, but as long as your terminal supports images, you should be able to adapt it just fine.
LOVE this
this one is clean asl
Because using docker can sometimes cause ownership issues if not properly configured in your docker-compose.yml, I just added an alias to ~/.zshrc to rectify that. -edit- Only run this script in your user owned directories, e.g. anything from ~/ (or /home/<your_username>) you might otherwise cause ownership issues for your system.
I’ve stolen a bunch of Git aliases from somewhere (I don’t remember where), here are the ones I ended up using the most:
I also often use
And finally some Nix things:
This makes me want spacemacs for the terminal
That’s a helpful one! I also add a function that creates a tmp directory, and cds to it which I frequently use to open a scratch space. I use it a lot for unpacking tar files, but for other stuff too.
(These are nushell functions)
Here’s a script I use a lot that creates a temporary directory, cds you into it, then cleans up after you exit. Ctrl-D to exit, and it takes you back to the directory you were in before.
Similar to what another user shared replying to this comment but mine is in bash + does these extra stuff.
I have a few interesting ones.
Download a video:
Execute the previous command as root:
Delete all the Docker things. I do this surprisingly often:
This is a handy one for detecting a hard link
I run this one pretty much every day. Regardless of the distro I’m using, it Updates All The Things:
I maintain an aliases file in GitLab with all the stuff I have in my environment if anyone is curious.
Fun fact if you are using bash,
!!
will evaluate to the previous command, so if you miss sudo on some long command, you can also just dosudo !!
.With the added benefit of it looking like you’re yelling at your prompt in order to get it to use sudo.
Ooooou I got a couple :3
This one is just a basic mirror fixing thing cuz sometimes I go a while without updating pacman:
This function I made to create virtual audio sinks so I can route audios via qpw and play earrape into discord calls if I want XD
Simple parser function I made that makes a whole repo using my git key so it’s not just locally created I kinda forgot why I made it tbh:
Awesome mpv function I made that allows for real time pitch+speed shifting via hotkeys and is flexible with extra parameters and shit:
alias fucking=‘sudo’
(my coworkers often usedprettyplease
instead)I have a bunch of the server aliases. I use those and gl the most.
Whatcha get in that log
Hahaha. Fucking autocorrect. Git log.
You can also use ssh shorthands in ~/.ssh/config
I do have the servers in
~/.ssh/config
. I just got tired of typingssh server
and wanted the be able to just typeserver
to ssh in.We almost have the same setup then, I use
in my .bash_aliases to parse the ~/.ssh/config file and cut off the 'ssh ’ part automatically for every Host I have in there.
That is a lovely setup. I’m gonna drop that into my
bash_aliases
so much more elegant than me adding the alias for each server.alias clip=‘xclip -selection clipboard’
When you pipe to this, for example
ls | clip
, it will stick the output of the command ran into the clipboard without needing to manually copy the output.I use a KDE variant of this that uses klipper instead (whatever you pipe to this will be available in klipper):
` #!/bin/sh
Pretty sure this only works on x distros?
wl-copy
andwl-paste
are for Wayland FYI.Yep, pretty sure you are right.
I’ve only used aliases twice so far. The first was to replace yt-dlp with a newer version because the version that comes pre-installed in Linux Mint is too outdated to download videos from YouTube. The second was because I needed something called “Nuget”. I don’t remember exactly what Nuget is but I think it was a dependency for some application I tried several months ago.
For the newer version of program, that’s why we have the $PATH. You put your program into one of the directories that is in your $PATH variable, then you can access your script or program from any of these like a regular program. Check the directories with
echo “$PATH” | tr ‘:’ ‘\n’
My custom scripts and programs directory is “~/.local/bin”, but it has to be in the $PATH variable too. Every program and script i put there can be run like any other program. You don’t even need an alias for this specific program in example.
Nuget is a the .NET package manager. Like npm or pip, but for .NET projects.
If you needed it for a published application that strikes me as fairly strange.
I looked through my bash history and it looks like I needed it to build an Xbox eeprom editor for Xemu. Xemu doesn’t (or at least didn’t, I haven’t used newer versions yet) have a built in eeprom editor and editing the Xbox eeprom is required for enabling both wide screen and higher resolutions for the games that support them natively.
I just looked at Xemu’s documentation, and it looks like they’ve added a link to an online eeprom editor, so the editor I used (which they do still link to) is no longer required.
Ah, if you need to build a .NET project that makes sense
.
I used this a lot when I had to deal with CSV files — it simply shows the data in a nice format. It’s an alias for the fish shell by the way.
One of favorites cds to the root of a project directory from a subdirectory,
I have a few:
3 scripts that are just docker compose up/down/pull, as scripts (remind me in 6 hours and I will post the scripts) so that it will CD to my compose folder, execute the command (with option for naming specific containers or blank for all) and then CD back to the directory I started in.
also a couple to easily power on/off my 4g modem
here we go:
dedup:
this removes duplicate lines, preserving line order
iter:
This executes a command for each line. It can also be used to compare two directories, ie:
fadeout:
lbn:
This plays “layered brown noise” by crysknife. It’s a great sleep aid.
here are some aliases:
Here is on that I actually don’t use, but want to use it in scripts. It is meant to be used by piping it. It’s simple branch with user interaction. I don’t even know if there is a standard program doing exactly that already.
Hey OP, consider using $XDG_RUNTIME_DIR instead of /tmp. It’s now the more proper place for these kinds of things to avoid permission issues, although I’m sure you’re on a single user system like most people. I have clipboard actions set to download with yt-dlp :)
My favorite aliases are:
alias dff=‘findmnt -D -t nosquashfs,notmpfs,nodevtmpfs,nofuse.portal,nocifs,nofuse.kio-fuse’
alias lt=‘ls -t | less’
Good idea! I’ll steal that but I would rather be able to give a directory path as parameter (and show in colors, and don’t pause if less than 1 page of content, and support the scrolwheel), also piping
ls
forces it to be 1 single column so might as well show more details, personally I’m gonna use this instead:Thanks for sharing! My ls is already aliased to ls -h --color=auto
On MacOS, to open the current directory in Finder:
alias f=‘open -a Finder .’
I use Clevis to auto-unlock my encrypted root partition with my TPM; this means when my boot partition is updated (E.G a kernel update), I have to update the PCR register values in my TPM. I do it with my little script
/usr/bin/update_pcr
:I run it with sudo and this handles it for me. The only issue is I can’t regenerate the binding immediately after the update; I have to reboot, manually enter my password to decrypt the drive, and then do it.
Now, if I were really fancy and could get it to correctly update the TPM binding immediately after the update, I would have something like an apt package shim with a hook that does it seamlessly. Honestly, I’m surprised that distributions haven’t developed robust support for this; the technology is clearly available (I’m using it), but no one seems to have made a user-friendly way for the common user to have TPM encryption in the installer.
Is clevis using an attestation server or is it all on a single machine? I’m interested in getting this set up but the noted lack of batteries included for this in the common distros makes it a somewhat tall order.
In my case, no; it’s all a single machine - it is in the initramfs and uses the system’s TPM to (relatively) securely store the keys.
It can be set up with an attestation server, but you certainly don’t have to do it. The Arch wiki has a really good article on getting it set up.
How difficult is it for an adversary to get in the middle of the TPM releasing the keys to LUKS? That’s why I would want attestation of some sort, but that makes it more complicated and thinking about how that would work in practice makes my head spin…
Vulnerabilities certainly do exist, but I’m pretty sure the attacker has to be well-equipped
I’d call it a protection against data getting cracked in a petty theft, but if your attack vector is much more than that, there are other measures you should probably take. I think Clevis also works with Yubikeys and similar, meaning the system won’t decrypt without it plugged in.
Heck, I think I know someone who just keeps their boot partition with the keys on it on a flash drive and hide it on their person.
Not exactly a single script, but I use scm breeze for git stuff. Has a ton of QoL features for working with git
github.com/scmbreeze/scm_breeze
I wrote a script called
please
. You inputplease
followed by any other command (e.g.please git clone
,please wget blahblah
) and a robotic voice will say “affirmative,” then the command will run, and when it completes, the robotic voice reads out the exit code (e.g. “completed successfully” or “failed with status 1” etc.)This is useful for when you have a command that takes a long time and you want to be alerted when it’s finished. And it’s a gentleman.
please
share the script?It’s full of random shit I put in as a joke, but here it is. You can use
please -s
to get lightly roasted when your command fails.spoiler
#!/bin/bash # announces success or failure of task if ! command -v “spd-say” > /dev/null then echo “spd-say must be installed.” exit -1 fi VOLUME=0 SERIOUS=1 FINISH_ONLY=0 if [ $# -ge 2 ] then if [ $1 == “-i” ] then # parse volume from command line VOLUME=$2 shift 2 fi fi spd-say -C # force stop speech synthesizer killall -q speech-dispatcher # androgynous voice # __sayfn=“spd-say -i -80 -t female3” # deep voice __sayfn=“spd-say -i $VOLUME -r -10 -p -100 -t male3” function _sayfn { $__sayfn “$@” 2>/dev/null if [ $? -ne 0 ] then $__sayfn “$@” fi } if [ $# -eq 0 ] || [ “$1” == “–help” ] then _sayfn “Directive required.” echo “Usage: please [-i volume] [-s|–serious] [-f|–finish] <command…>” echo " please [-i volume] --say text" echo " -i: volume in range -100 to +100" echo " --serious, -s: no silliness. Serious only. (Just kidding.)" echo " --finish, -f: do not announce start" exit -2 fi # threading issue sleep 0.001 if [ $# -ge 2 ] then if [ $1 == “–say” ] then # _sayfn the given line shift 1 _sayfn “$@” exit 0 fi if [ $1 == “–serious” ] || [ $1 == “-s” ] then shift 1 SERIOUS=0 fi if [ $1 == “–finish” ] || [ $1 == “-f” ] then shift 1 FINISH_ONLY=1 fi fi i=$(shuf -n1 -e “.” “!”) # inflection on voice if [ “$FINISH_ONLY” -eq 0 ] then if [ “$SERIOUS” -eq 0 ] then # startup lines (randomized for character) _sayfn -r -5 -x “.<break time=\“60ms\”/>$(shuf -n1 -e \ ‘Proceeding As Directed…’ \ ‘By your command…’ \ ‘By your command…’ \ ‘By the power ov greyskaall!’ \ ‘By your command,line…’ \ ‘As you wish…’ \ ‘Stand by.’ \ ‘Engaged…’ \ ‘Initializing…’ \ ‘Activating’ \ ‘At once!’ \ “Post Haste$i” \ ‘it shall be done immediately’ \ ‘Very well.’ \ ‘It shall be so.’ \ “righty-o$i” \ “Affirmative$i” \ “Acknowledged$i” \ “Confirmed$i” \ )” else _sayfn -r -5 -x “.<break time=\“60ms\”/>Engaged…” fi if [ $? -ne 0 ] then _sayfn “Speech engine failure.” echo “Failed to run speech engine. Cancelling task.” exit -3 fi fi if ! command -v “$1” > /dev/null then # _sayfn a little faster because this exits fast. _sayfn -r +10 “Unable to comply? invalid command.” >&2 echo “$1: command not found.” exit -4 fi eval " $@" result=$? i=$(shuf -n1 -e “,” “!” “?”) # inflection on voice transition=$(shuf -n1 -e “; error” “, with error” “; status”) taskname=$(shuf -n1 -e “task” “task” “command” “objective” “mission” “procedure” “routine”) errtext=$(shuf -n1 -e “Task_failed” “Task_failed” “Task_resulted_in_failure” “Procedure_terminated_in_an_error” “An_error_has_occurred” “Auxilliary_system_failure” “system_failure”) consolation=$(shuf -n1 -e “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “” “Attention required.” “Attention is required!” “Perhaps It was inevitable.” “It may or may not be cause for alarm.” “Perhaps Machines too, are fallible.” “Apologies” “Hopefully nobody else was watching” “shazbot” “maybe next time.” “Nobody could have predicted this outcome.” “I’m very sorry.” “how unfortunate.” “remember: don’t panic” “oh dear” “Nothing could have been done to prevent this” “Remember: No disasters are fully preventable” “perhaps the only winning move is not to play” “Remember: Failure is our teacher, not our undertaker.” “Remember: If at first you don’t succeed… try again.” “Remember: If at first you don’t succeed… try… try again.” “But your friends still love you.” “Remember: the machine is not your enemy.” “Command?” “Awaiting further instructions.” “Remember: Logic is the beginning of wisdom… not the end of it.” “Remember: When you eliminate the impossible, whatever remains, however improbable, must be the truth.” “Keep at it. Victory is withi
That’s so neat
I once experimented with something similar, except it was supported to trigger my smart speaker and drop into another part of the house to tell me.
Honestly, I really need to replace my proprietary smart speaker system with something self-hosted; it’s just I only recently have had the time to start cinsidering.
You can also use something like notifyd to generate a pop up for visual feedback :) I can’t remember the exact command right now though. Differs per distro or desktop environment, obviously.
notify-send ‘command finished!’
works pretty wellAlso,
printf ‘\a’
will output an alert bell character which should make the terminal beep/blink and be highlighted for attention by your wm/compositor if it’s unfocused.I have that aliased to
a
to get notified whenever a long running command finishes just by adding;a
at the end.I have a collection of about 8 machines around the house (a lot of Raspberry Pi) that I ssh around to from various points.
I have setup scripts named: ssp1 ssp2 ssba ss2p etc. to ssh into the various machines, and of course shared public ssh keys among them to skip the password prompt. So, yes, once you are “in” one machine in my network, if you know this, you are “in” all of them, but… it’s bloody convenient.
I used to have scripts like that, but eventually switched to ssh aliases. You can set up an alias for each machine in
~/.ssh/config
with lines like this:Then access with
ssh p1
. Slightly more typing, but avoids adding more commands to your $PATH. Also has the benefit of letting you use the same alias with other ssh-related commands like sftp.jmpd(jump directory): fuzzy finds and opens directory with fzf
alias fuck=‘sudo $(history -p \!\!)’
sudo !!
Try it, and you will find it just does not provide the same emotional peace.
I like to imagine I’m yelling it. SUDO!!!
:D
Nice
Why not use thefuck which also corrects typos?
Because i’m not a psychopath, just autistic.
I have the same but it’s called “please”
i touch computers since almost 40 years. “Please” stopped being an option somewhere in the early 2000’s.
g-push
This tmux wrapper is remarkably convenient:
Usage:
I alias traditional stuff to better, usually drop-in versions of that thing on computers that have the better thing. I often forget which systems have the better thing, so this helps me get the better experience if I was able to install it at some point. For example I alias cat to bat, or top to htop, or dig to drill, etc.
alias ed=$EDITOR
is my most used alias by far.I wrote this suite of scripts a few years ago and still use them to:
cfg/cfg.sh
if it’s the first time using the toolsetup.sh
to configure the environment into a familiar/productive stateThe tools are flexible on hardware (more directed toward x64 systems at this time), and I (almost) never have to worry about OS upgrades. Just boot into a newer live OS image once it’s ready. They are still a work-in-progress and still have a few customizations that I should abstract for more general use, but it’s FOSS in case anyone has merge requests, issues, suggestions, etc.
Well, my full
functions.sh
won’t fit in a comment, so here’s 2 of my more unique functions that makes life a little easier when contributing to busy OSS projects:Since 720p downloading isn’t really available on yt-dlp anymore, I made an alias for it
i use
to display images in my terminal pretty simple but nice
I have that one too, but my alias is called icat
ganis
:git add -A && sudo nixos-rebuild switch --impure -j$(nproc)
Everyone who uses nixos probably has a similar alias set x)
alias ed=$EDITOR
Extremely convenient on a qwerty keyboard.
This should probably be a default nowadays. Does even a single person here use the real
ed
?Me. Along with vi depending on my mood.
To save videos from certain streaming sites that are not supported by yt-dlp, I catch the M3U playlist used by the page and with that I use this script that gets ffmpeg to put together the pieces into a single file.
alias sl=‘ls | while IFS= read -r line; do while IFS= read -r -n1 char; do if [[ -z “$char” ]]; then printf “\n”; else printf “%s” “$char”; sleep 0.05; fi; done <<< “$line”; done’
I can’t easily check if it works until I get home to my laptop, but you get the idea
real ones watch the train of shame
None, I like to type
I PAID MONEY FOR THIS KEYBOARD AND GOD DAMN I AM GOING TO TYPE ON IT
alias scr=screen -dRU
I don’t know why Screen has any other flags. I do not want to bother learning the keyboard shortcuts for tmux even though its probably works better
well i have a script. ive named it “shazam”. it either creates or attachs to a tmux session named after the base name of the dir (first arg or current working directory). i also have “fzf-shazam” as the same suggests itll open a fzf finder to choose a dir to “shazam”
alias nmtui=“NEWT_COLORS=‘root=black,black;window=black,black;border=white,black;listbox=white,black;label=blue,black;checkbox=red,black;title=green,black;button=white,red;actsellistbox=white,red;actlistbox=white,gray;compactbutton=white,gray;actcheckbox=white,blue;entry=lightgray,black;textbox=blue,black’ nmtui”
It’s
nmtui
but pretty!on most of my systems I get tired of constantly
ls
ing after acd
so I combine them:(excuse if this doesn’t work, I am writing this from memory)
I also wrote a function to access docker commands quicker on my Truenas system. If passed nothing, it enters the docker jailmaker system, else it passes the command to docker running inside the system.
I have a few similar shortcuts for programs inside jailmaker and long directories that I got sick of typing out.
I made this one to find binaries in NixOs and other systems
Then I made this one to, if I have a shell o opened inside neovim it will tell the neovim process running the shell to open a file on it, instead of starting a new process
alias cls=clear
My first language was QB, so it makes me chuckle.
Also,
alias cim=vim
. If I had a penny…I also have cls aliased to clear! I used to use windows terminal and found myself compulsively typing cls when I moved to linux.
alias gimme=‘git checkout’
Twins(-ish)!
This lets you run
git cd
to go to the root of your repo, orgit cd foo/bar
to go to a path relative to that root. You can’t do it as an alias because it’s conditional, and you can’t do it as agit-cd
command because that wouldn’t affect the current shell.alias cd…=“cd …”
I have something similar.
I did have code that would generate these automatically but Idk where it is.
I don’t have anything too fancy. I use [theFuck(github.com/nvbn/thefuck) to handle typos, and I have some variables set to common directories that I use.
Currently using this to resize screenshots in a Word doc
#Requires AutoHotkey v2.0
^+1:: { Send “{RButton}z{Tab 3}4{Enter}” }
Is this just meant to make git clone always clone recursively?
Can’t you do this with aliases in your .gitconfig?
yes it is. idk😄 i have a similar one for github-cli
alias qr=‘qrencode -t ansiutf8’
This makes qr codes in the terminal.
needs the
qrencode
packageExample usage and output:
Polls for potential zombie processes:
Technically not an alias, because I just use nushell’s history + autocompletion everytime I use it, but one could alias it. I think I might even write a custom command for it, with
path
argument, some day. Anyway, here it goes:rsync -aPh -e “ssh -p 2222” test@172.16.0.86:/storage/emulated/0/PicturesArchive/ ~/PicturesArchive/
I run an ssh daemon on my phone, and use this snippet to back up my photos.