Last active
October 29, 2018 23:22
-
-
Save atucom/5140645 to your computer and use it in GitHub Desktop.
tmux logging hack. Works just like GNU screen "logfile"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#place this code in your .bashrc or .profile and have fun :D | |
if [[ $(uname) = "Darwin" ]]; then #this is for OSX Machines | |
#This sets up auto logging to $HOME/logs if its a tmux window | |
if [[ $TERM = "screen" ]] && [[ $(ps $PPID -o comm=) = "tmux" ]] ; then | |
read -p "Enter Log Prefix: " log_prefix | |
logname="${log_prefix}_$(date '+%d.%m.%Y-%H:%M:%S').tmux.log" | |
mkdir $HOME/logs 2> /dev/null | |
script -t 1 $HOME/logs/${logname} bash -login | |
exit | |
fi | |
fi | |
#LINUX SPECIFIC CODE | |
if [[ $(uname) = "Linux" ]]; then #this is for Linux | |
if [[ $TERM = "screen" ]] && [[ $(ps -p $PPID -o comm=) = "tmux" ]]; then | |
read -p "Enter Log Prefix: " log_prefix | |
logname="${log_prefix}_$(date '+%d.%m.%Y-%H:%M:%S').tmux.log" | |
mkdir $HOME/logs 2> /dev/null | |
script -f $HOME/logs/${logname} | |
exit | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment