Skip to content

Instantly share code, notes, and snippets.

@carlthewebmaster
Last active December 10, 2015 12:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlthewebmaster/4432429 to your computer and use it in GitHub Desktop.
Save carlthewebmaster/4432429 to your computer and use it in GitHub Desktop.
shell script to run arch linux on ChromeOS, based on https://gist.github.com/4140706
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# Put your fun stuff here.
if uname -a | grep -q SAMSUNG ; then
echo "Booting into ChromeOS Linux"
sudo mount -i -o remount,exec /home/chronos/user/
else
echo "Welcome to Arch Linux: `uname -a`"
# Configure colors, if available.
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
c_reset='\[\e[0m\]'
c_user='\[\e[1;33m\]'
c_path='\[\e[0;33m\]'
c_git_cleancleann='\[\e[0;36m\]'
c_git_dirty='\[\e[0;35m\]'
else
c_reset=
c_user=
c_git_cleancleann_path=
c_git_clean=
c_git_dirty=
fi
# Function to assemble the Git parsingart of our prompt.
git_prompt ()
{
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null | sed -n '/^\*/s/^\* //p')
if git diff --quiet 2>/dev/null >&2; then
git_color="$c_git_clean"
else
git_color="$c_git_dirty"
fi
echo "[$git_color$git_branch${c_reset}]"
}
# Thy holy prompt.
PROMPT_COMMAND='PS1="${c_user}\u${c_reset}@${c_user}\h${c_reset}:${c_path}\w${c_reset}$(git_prompt)\$ "'
fi
alias go="~/local-dev/scripts/go"
alias godev='cd ~/local-dev'
alias gonode='cd ~/local-dev/node-dev'
" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar <Bram@vim.org>
" Last change: 2011 Apr 15
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
set backupdir=~/.vim/backups,.
set directory=~/.vim/backups,.
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
#!/bin/bash
if uname -a | grep -q SAMSUNG ; then
echo "Changing Root to Arch Linux"
sudo cp /etc/resolv.conf /usr/local/arch/etc/resolv.conf
sudo mount -o bind /dev /usr/local/arch/dev
sudo mount -t devpts none /usr/local/arch/dev/pts
# link to the chronos home drive to get access to the Downloads folder
sudo mount -o bind /home/chronos/user /usr/local/arch/root
sudo mount -t proc proc /usr/local/arch/proc
sudo mount -t sysfs sys /usr/local/arch/sys
sudo chroot /usr/local/arch /bin/bash
sudo umount /usr/local/arch/dev/pts
sudo umount /usr/local/arch/dev
sudo umount /usr/local/arch/proc
sudo umount /usr/local/arch/sys
sudo umount /usr/local/arch/root
else
# don't change to arch linux if it's already running!
echo "You're already running `uname -a`"
exit 0
fi
@macton
Copy link

macton commented Jan 29, 2013

Variation on a theme: Here are my notes for a similar setup (except on external sdcard) https://gist.github.com/4632677

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment