Skip to content

Instantly share code, notes, and snippets.

@osteele
Created April 24, 2018 12:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osteele/c9a3bdb76f16ec2ccf176bfc6be0a924 to your computer and use it in GitHub Desktop.
Save osteele/c9a3bdb76f16ec2ccf176bfc6be0a924 to your computer and use it in GitHub Desktop.
Chris Morgan's bash-for-recording

A script bash-for-recording, for invocation by termrec. This does the following:

  • Set the window size to 80×24
  • Set HOME to a new empty directory
  • Set USER and NAME to dummy values (creating an actual new throwaway user account would be better here)
  • Set TERM to xterm-256color
  • Clear the environment (env -i)
  • Set a deliberately very simple and obvious prompt (which sets the title as well)
  • Clear the screen
  • Finally, start a nice clean bash profile

Author: Chris Morgan https://chrismorgan.info

Source: https://news.ycombinator.com/item?id=16911032

#!/bin/bash
# Author: Chris Morgan <https://chrismorgan.info>
# Source: https://news.ycombinator.com/item?id=16911032
# Start a new bash shell with a severely filtered environment and no initfile.
if [ -z "$_BFR_RUNNING" ]; then
env -i \
_BFR_RUNNING=1 \
PATH="$PATH" \
LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
TERM="$TERM" \
SHELL="$SHELL" \
USER="$USER" \
HOME="$HOME/bfr-home" \
LANG="$LANG" \
bash --init-file "$0" "$@" <&0
exit $?
else
unset _BFR_RUNNING
fi
# What remains of this file is the initfile.
USER=user
HOSTNAME=hostname
PS1='\n\[\033[32;45;1m\]\w\[\033[m\]\$ '
eval "$(dircolors -b)"
alias ls='ls --color=auto'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment