1
0
Fork 0

Compare commits

...

3 Commits

@ -0,0 +1,6 @@
#!/bin/bash -e
# Check available updates for manually installed Python packages.
table="$(pip list --user --outdated)"
echo "$table"
list="$(echo "$table" | tail -n +3 | awk '{print $1}' | tr '\n' ' ')"
echo "Update the all with: $ pip install -U $list"

@ -0,0 +1,7 @@
#!/bin/bash -ex
# Convert FLACs in a directory to MP3 files (V0, but configure it below).
# Requires fdfind and ffmpeg.
fdfind -t f -e flac . "$1" | while read -r flac; do
mp3="${flac/%flac/mp3}"
ffmpeg -i "$flac" -codec:a libmp3lame -q:a 0 "$mp3" && rm "$flac"
done

@ -0,0 +1,9 @@
#!/bin/bash
# Install scripts from this repo using our neighbour paf.sh.
# Requires fdfind and fzf to work.
script_dir="$( cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )"
paf="$script_dir/paf.sh"
fdfind -t x | fzf --multi --layout=reverse --header="Pick scripts to install" \
| while read -r script; do "$paf" "$script"; done

@ -1,16 +0,0 @@
#!/bin/bash
ensure_has() {
if ! command -v "$1" > /dev/null; then
echo "Can't find $1."
exit 1
fi
}
ensure_has fdfind
ensure_has fzf
ensure_has install-script
fdfind -t x \
| fzf -m --layout=reverse \
| while read -r script; do install-script "$script"; done

@ -0,0 +1,16 @@
#!/bin/bash -e
# A script to install other scripts! Create a symbolic link to the path passed
# as first argument in ~/.local/bin and strip the extension. If a second
# argument is passed, this name is used (unstripped) instead. If a file already
# exists at the link path, the script fails (last command is ln itself). This is
# intentional.
script_dir="$HOME/.local/bin"
script="$(realpath "$1")"
if [ -n "$2" ]; then
script_name="$2"
else
script_name="$(basename "$script")"
script_name="${script_name%.*}" # remove extension
fi
ln -s "$script" "$script_dir/$script_name"

@ -1,57 +0,0 @@
#!/bin/bash -e
# Upload a text file to a server through SSH so that it can be shared.
# This script expects the server can serve files on the Web. Also expects curl.
# It uses an HTML template instead of the raw text file because browsers
# sometimes do not expect UTF-8 by default and this is always what I upload.
#
# You need to provide those 3 env variables:
# - REMOTE_DEST: the SSH destination to reach
# - REMOTE_WWW: the remote path where the HTML file will be stored
# - REMOTE_URL: the URL of the directory to print; file name is appended
usage() {
echo "Usage: $0 text_file"
echo "Upload a text file to a simple HTML template on a server."
}
[ $# -ne 1 ] && usage && exit
# If a file exists at that path, it is sourced; you can put your env vars here.
CONFIG_PATH="$HOME/.config/upload-text.conf"
[ -f "$CONFIG_PATH" ] && . "$CONFIG_PATH"
# Check for our environment variables.
if [ ! -v REMOTE_DEST ] || [ ! -v REMOTE_WWW ] || [ ! -v REMOTE_URL ]; then
echo "You need to provide all the required environment variables."
exit
fi
# Generate a simple HTML page from the content.
BASENAME="$(basename "$1")"
HTML_FILE="$(mktemp)"
cat << EOF > "$HTML_FILE"
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>$BASENAME</title>
<style>
body { max-width: 40em; }
</style>
</head>
<body>
<pre>
$(cat "$1")
</pre>
</body>
</html>
EOF
# Upload the HTML file through SSH. Using SSH rather than SCP allows us to write
# the file in one connection while setting appropriate rights.
REMOTE_FILE="$(mktemp -u -p "$REMOTE_WWW" XXXXXXXXXX.html)"
cat "$HTML_FILE" | ssh -q "$REMOTE_DEST" "umask 027; cat > '$REMOTE_FILE'"
rm "$HTML_FILE"
# Show the remote file path.
echo "$REMOTE_URL/$(basename "$REMOTE_FILE")"
Loading…
Cancel
Save