jmpd(jump directory): fuzzy finds and opens directory with fzf
# fish shell
function jmpd
set _selection $(fzf --walker=dir);
if test -n "$_selection"
cd "$_selection";
end
end
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
jmpd(jump directory): fuzzy finds and opens directory with fzf
# fish shell
function jmpd
set _selection $(fzf --walker=dir);
if test -n "$_selection"
cd "$_selection";
end
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.
alias cls=clear
My first language was QB, so it makes me chuckle.
Also, alias cim=vim
. If I had a penny...
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!
function seesv
column -s, -t < $argv[1] | less -#2 -N -S
end
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.
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
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.
#!/bin/bash
if [ "$1" == "-h" ] || [ $# -lt 2 ]; then
echo Download a video from a playlist into a single file
echo usage: $(basename $0) PLAYLIST OUTPUT_VID
exit
fi
nbparts=$(grep ^[^#] $1 | wc -l)
echo -e "\e[38;5;202m Downloading" $(( nbparts - 1 )) "parts \e[00m"
time ffmpeg -hide_banner -allowed_extensions ALL -protocol_whitelist file,http,https,tcp,tls,crypto -i $1 -codec copy $2
I have a few interesting ones.
Download a video:
alias yt="yt-dlp -o '%(title)s-%(id)s.%(ext)s' "
Execute the previous command as root:
alias please='sudo $(fc -n -l -1)'
Delete all the Docker things. I do this surprisingly often:
alias docker-nuke="docker system prune --all --volumes --force"
This is a handy one for detecting a hard link
function is-hardlink {
count=$(stat -c %h -- "${1}")
if [ "${count}" -gt 1 ]; then
echo "Yes. There are ${count} links to this file."
else
echo "Nope. This file is unique."
fi
}
I run this one pretty much every day. Regardless of the distro I'm using, it Updates All The Things:
function up {
if [[ $(command -v yay) ]]; then
yay -Syu --noconfirm
yay -Yc --noconfirm
elif [[ $(command -v apt) ]]; then
sudo apt update
sudo apt upgrade -y
sudo apt autoremove -y
fi
flatpak update --assumeyes
flatpak remove --unused --assumeyes
}
I maintain an aliases file in GitLab with all the stuff I have in my environment if anyone is curious.
alias bat="batcat"
alias msc="ncmpcpp"
alias xcp="xclip -selection clipboard"
alias wgq="sudo wg-quick"
also a couple to easily power on/off my 4g modem
$ which diffuc
diffuc: aliased to diff -uw --color=always
$ which grepnir
grepnir: aliased to grep -niIr
$ cat `which ts`
#!/bin/bash
if [ "$#" -lt 1 ]; then
tmux list-sessions
exit
fi
if ! tmux attach -t "$1"
then
tmux new-session -s "$1"
fi
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
:
#!/bin/bash
clevis luks regen -d /dev/nvme1n1p3 -s 1 tpm2
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.
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.
alias yt-dlp='/home/j/yt-dlp/yt-dlp'
alias nuget="mono /usr/local/bin/nuget.exe"
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
On MacOS, to open the current directory in Finder: alias f='open -a Finder .'
git() {
if [ "$1" = clone ]; then
shift
set -- clone --recursive "$@"
fi
command git "$@"
}
Currently using this to resize screenshots in a Word doc
#Requires AutoHotkey v2.0
^+1:: { Send "{RButton}z{Tab 3}4{Enter}" }
alias gl='git log'
alias server-name-here='ssh server-name-here'
I have a bunch of the server aliases. I use those and gl the most.
You can also use ssh shorthands in ~/.ssh/config
I do have the servers in ~/.ssh/config
. I just got tired of typing ssh server
and wanted the be able to just type server
to ssh in.
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'
I don't have anything too fancy. I use [theFuck(https://github.com/nvbn/thefuck) to handle typos, and I have some variables set to common directories that I use.
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 neat
# grep search the current directory
function lg() {
ls -alt | grep $1
}
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:
# switch sinks
toggle_audio() {
# Find headset sink ID dynamically
headset_id=$(pactl list sinks short | grep "Plantronics" | awk '{print $1}')
# Find speakers sink ID dynamically
speakers_id=$(pactl list sinks short | grep "pci-0000_05_00.6" | awk '{print $1}')
# Get current default sink
current_sink=$(pactl get-default-sink)
# Get current sink ID
current_id=$(pactl list sinks short | grep "$current_sink" | awk '{print $1}')
# Toggle between the two
if [ "$current_id" = "$headset_id" ]; then
pactl set-default-sink "$speakers_id"
echo "Switched to speakers (Sink $speakers_id)"
else
pactl set-default-sink "$headset_id"
echo "Switched to headset (Sink $headset_id)"
fi
}
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....
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.
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.
g-push
git push origin `git branch --show`