Configure BASH

From AwkwardTV
Jump to: navigation, search

Setting up the Environment

Although the Apple TV might allow you to login remotely through SSH (see Install SSH), it doesn't necessarily set up the terminal environment as you might expect it on a standard Mac installation. For instance, the command prompt on my Mac reads:

[riquedafreak@localhost /]$

While the Apple TV's command prompt reads something like this:


The following files & instructions shows you how to customize the Bash environment. Traditionally you would create the /etc/bashrc file, however, the Apple TV does not have this feature enabled out of the box.

From your computer run:

scp -1 /etc/bashrc frontrow@appletv:
scp -1 /etc/profile frontrow@appletv:

From your Apple TV run:

sudo mv ~/bashrc /etc/bashrc
sudo mv ~/profile /etc/profile

Now the appropriate configuration files have been modified to show a prompt from your Apple TV like this:


These settings will not take place until a reboot has occurred, you can force a reboot with the following command from your Apple TV's command prompt:

sudo shutdown -r now

Making the Most Out Of Bash Configs

If you read your default bashrc file, the default command prompt reads:

PS1='\h:\w \u\$ ';

Since I spend a lot of time on the command prompt, I like to see the clear distinction between one prompt and another, unfortunately the default command prompt is in black and white and most of the time fades into the rest of the text. I've done a bit of research and came up with a command prompt that is distinct from the rest of the text, and clearly shows you what path you're in.

Replace the aforementioned line with:

PS1="\[\e[0;34m\][\[\e[1;34m\]\u\[\e[0;34m\]@\h \[\e[31m\]\w\[\e[0;34m]\]\$\[\e[0m\] ";


I also spend a lot of time at the command prompt. And I've set it up to show the current working directory in the title bar of the window. Keeps the prompt nice and short. I followed "solution 1" in this article to do it, but modified the 2nd line to this:

PS1='[\h] \u\$ ';

College 05:32, 26 May 2007 (CEST)

History backwards search

A feature I use a lot is typing the first characters of a command and typing PageUp to recall recent commands I issued starting with these chracters.

This is customized with an inputrc file. Either a system-wide /etc/inputrc or a user-specific ~/.inputrc.

As an example, one can use the following file (found at

$if Bash
    # Search history back and forward using page-up and page-down
    "\e[5~": history-search-backward
    "\e[6~": history-search-forward

    # Completion
    set match-hidden-files off
    set page-completions off
    set completion-query-items 350
    set show-all-if-ambiguous on


If you use a system-wide /etc/inputrc, edit /etc/bashrc:


And edit /etc/profile:

# System-wide .profile for sh(1)

if [ -x /usr/libexec/path_helper ]; then
  eval `/usr/libexec/path_helper -s`

if [ "${BASH-no}" != "no" ]; then
  [ -r /etc/bashrc ] && . /etc/bashrc

Single user customization

If you want to customize the bash shell for a single user (eg frontrow), you will need 2 files:


An example for ~/.bash_profile would be:

# This file is sourced by bash for login shells.  The following line
# runs your .bashrc and is recommended by the bash info pages.
[[ -f ~/.bashrc ]] && . ~/.bashrc

And the ~/.bashrc could hold:

alias ll='ls -laG'
alias ed='nano -w'