Skip to content

Commit

Permalink
minor script changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Speyll committed Nov 8, 2024
1 parent 5e69ad5 commit 0e9bc36
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 38 deletions.
8 changes: 8 additions & 0 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ __ehc()
fi
}

# Function to not log a command in history.
nhist() {
HISTFILE=/dev/null
bash -ic "$*"
history -d $(history 1)
}


# `tm` will allow you to select your tmux session via fzf.
tm() {
[[ -n "$TMUX" ]] && change="switch-client" || change="attach-session"
Expand Down
28 changes: 13 additions & 15 deletions .config/aliasrc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ alias \
rsync-ssh="rsync -avzh --progress -e ssh" \
rsync-net="rsync -avzh --progress"

# Use neovim for vim if present.
command -v nvim >/dev/null && alias vim="nvim" vimdiff="nvim -d"

# Verbosity and settings that you pretty much just always are going to want.
alias \
cp="cp -iv" \
Expand All @@ -59,17 +56,18 @@ alias \
clear="tput clear" \
reset="tput reset"

# Git alias
alias gcl='git clone --depth 1'

# Tmux
alias tmux="tmux -f ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"

# Python local server
alias pyserv="python3 -m http.server"
# Network aliases
alias \
gcl='git clone --depth 1' \
nfs-mount="sudo mount -t nfs -o soft,timeo=50,retrans=2,intr,noac" \
ssh-mount="sshfs -o reconnect,ServerAliveInterval=15,ServerAliveCountMax=3,sshfs_sync"

# Clear dups from bash history
alias cleanup-history="tac \$HOME/.bash_history | awk '!seen[\$0]++' | tac | sed 's/[[:space:]]\+$//' > /tmp/.bash_history_tmp && mv -f /tmp/.bash_history_tmp \$HOME/.bash_history > /dev/null 2>&1"
# Utilities aliases
alias \
pyserv="python3 -m http.server" \
cleanup-history="tac \$HOME/.bash_history | awk '!seen[\$0]++' | tac | sed 's/[[:space:]]\+$//' > /tmp/.bash_history_tmp && mv -f /tmp/.bash_history_tmp \$HOME/.bash_history > /dev/null 2>&1" \
cleanup-gamescope='pkill -9 -f "wine|wineserver|winedevice.exe|explorer.exe|gamescope-wl"' \

# Cleanup gamescope leftovers
alias cleanup-gamescope='pkill -9 -f "wine|wineserver|winedevice.exe|explorer.exe|gamescope-wl"'
# Config aliases
command -v nvim >/dev/null && alias vim="nvim" vimdiff="nvim -d"
alias tmux="tmux -f ${XDG_CONFIG_HOME:-$HOME/.config}/tmux/tmux.conf"
30 changes: 30 additions & 0 deletions .local/bin/dircomp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/sh

# Check if directories are provided
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Usage: $0 <dir1> <dir2>"
exit 1
fi

dir1="$1"
dir2="$2"

# Ensure both directories exist
if [ ! -d "$dir1" ] || [ ! -d "$dir2" ]; then
echo "Error: One or both directories do not exist."
exit 1
fi

# Create temporary files for the sorted file lists
tmp1=$(mktemp)
tmp2=$(mktemp)

# List files in both directories and sort them
find "$dir1" -type f -exec realpath --relative-to="$dir1" {} \; | sort > "$tmp1"
find "$dir2" -type f -exec realpath --relative-to="$dir2" {} \; | sort > "$tmp2"

# Compare file lists using comm
comm -23 "$tmp1" "$tmp2"

# Clean up temporary files
rm "$tmp1" "$tmp2"
9 changes: 5 additions & 4 deletions .local/bin/ff-enc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ extract_audio() {
done
find_command="${find_command% -o } \\)"

cover_timestamp="00:05:00" # Default timestamp for cover art extraction
cover_timestamp="${timestamp:-00:05:00}" # Default to 5-minute mark if not specified

eval "$find_command" | while read -r video; do
# Check if the file exists
if [ -f "$video" ]; then
Expand All @@ -78,7 +79,7 @@ extract_audio() {
echo "Extracted audio from $video without re-encoding"

# Embed the cover art into the m4a file
output_with_cover="extAudios/${video%.*}.m4a"
output_with_cover="$audio_output_dir/${video%.*}.m4a"
ffmpeg -nostdin -y -i "$output_audio" -i "$cover_art" -map 0:a -map 1 -c copy \
-metadata:s:v title="album cover" -metadata:s:v comment="cover (front)" \
-disposition:v:0 attached_pic "$output_with_cover"
Expand Down Expand Up @@ -133,7 +134,7 @@ EOF
;;
-a|--audio)
action="audio"
timestamp="$2"
timestamp="${2:-00:05:00}"
shift
;;
-c|--crop)
Expand Down Expand Up @@ -174,5 +175,5 @@ esac
# Shutdown if requested
if [ "$shutdown" = true ]; then
echo "Processing complete. Shutting down..."
shutdown now
sudo poweroff now
fi
19 changes: 0 additions & 19 deletions .local/bin/finddiff

This file was deleted.

0 comments on commit 0e9bc36

Please sign in to comment.