Dawid Ciężarkiewicz aka `dpc`

notes on software engineering, Open Source hacking, cryptocurrencies etc.


# Reattach to (or spawn new if not existing) tmux session
# tmux session <session_name> [ <session_directory> ]

export STY="tmux-$1"
if [ ! -z "$2" ]; then

RC="$(readlink -f "$RC")"

if ! tmux has-session -t "$1" 2>/dev/null ; then
    if [ ! -z "$RC" -a -f "$RC" ] ; then
        tmux new-session -d -s "$1" "tmux move-window -t 9; exec tmux source-file \"$RC\""
        tmux new-session -d -s "$1"

exec tmux attach-session -t "$1"


# Spawn tmux session in current directory
# use path's sha256 hash as session name

exec "$HOME/bin/tmux-session" "$(echo "$PWD" | sha256sum | awk '{ print $1 }')" "$PWD"

#shell #tool

Having a lot of RAM nowadays is relatively cheap and Linux can make a good use of it. With tools like preload most of Linux distributions are trying to proactively read things that you might want to use soon.

However if your desktop have a ridiculous amount of memory (mine has 32GB) it may take ages for these tools to make use of all that memory. And why would you pay for it and then let it just sit idle instead of working for you?

The thing is: you can do much better, because you know what you are going to use in the future.

So, as always, let’s write a tiny script under the name precache.


exec nice -n 20 ionice -c 3 find "${1:-.}" -xdev -type f \
    -exec nice -n 20 ionice -c 3 cat '{}' \; > /dev/null

Personally I keep it as $HOME/bin/precache.