mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-21 19:11:30 +01:00
version 2.0
This commit is contained in:
parent
d8d2c7a512
commit
0ca03a69ac
29
README.md
29
README.md
|
@ -4,8 +4,8 @@
|
||||||
## Description ##
|
## Description ##
|
||||||
|
|
||||||
1. brethil_dotfile.sh: main file sourced by ~/.bash_profile
|
1. brethil_dotfile.sh: main file sourced by ~/.bash_profile
|
||||||
2. aliases.sh: contains alias definitions (sources ~/.bash_aliases)
|
2. aliases.sh: contains alias definitions (sources ~/.dotfiles_aliases)
|
||||||
3. functions.sh: contains function definitions (sources ~/.bash_functions)
|
3. functions.sh: contains function definitions (sources ~/.dotfiles_functions)
|
||||||
4. colors.sh: contains color definitions
|
4. colors.sh: contains color definitions
|
||||||
5. install.sh: run to install brethil's dotfiles
|
5. install.sh: run to install brethil's dotfiles
|
||||||
|
|
||||||
|
@ -15,30 +15,37 @@ Copy the dotfiles folder to the location where you want to keep it and then run
|
||||||
$ cd dotfiles && bash install.sh
|
$ cd dotfiles && bash install.sh
|
||||||
|
|
||||||
Installs oh-my-zsh and sources aliases.sh, functions.sh and colors.sh, as well as installing
|
Installs oh-my-zsh and sources aliases.sh, functions.sh and colors.sh, as well as installing
|
||||||
a a few utilities (see `install.sh`)
|
a a few utilities (see `install.sh`).
|
||||||
|
|
||||||
### Installed programs ###
|
### Installed programs ###
|
||||||
|
|
||||||
0. oh-my-zsh (zsh config)
|
0. oh-my-zsh (zsh config framework, lots of plugins available at https://github.com/robbyrussell/oh-my-zsh/wiki/Plugins)
|
||||||
1. byobu (wrapper/config for tmux, a screen multiplexer)
|
1. byobu (wrapper/config for tmux, a screen multiplexer)
|
||||||
2. grc (generic colourizer, colours output of any command)
|
2. grc/ccze (output colorizers, color output of any command). Usage:
|
||||||
|
$ grc programname
|
||||||
|
$ programname | ccze
|
||||||
3. bmon (bandwidth monitor, shows graphs for bandwith usage)
|
3. bmon (bandwidth monitor, shows graphs for bandwith usage)
|
||||||
3. rmate remote for Textmate (can be called with `mate`/`rmate`)
|
4. rmate remote for Textmate (can be called with `mate`/`rmate`)
|
||||||
|
5. mtr (my traceroute, traceroute+ping network utility)
|
||||||
|
|
||||||
### Available Commands ###
|
|
||||||
|
|
||||||
|
### Available Functions ###
|
||||||
|
|
||||||
|
0. `cheat`, show cheat sheet for commands using cheat.sh (`cheat commandname`)
|
||||||
1. Quickly edit/reload profile (`esource`/`resource`)
|
1. Quickly edit/reload profile (`esource`/`resource`)
|
||||||
2. `ramdisk` (only on OSX) create a RAM disk. Default size: 1GB
|
2. `ramdisk` (only on OSX) create a RAM disk. Default size: 1GB
|
||||||
` ramdisk 4`
|
` ramdisk 4`
|
||||||
creates a 4GB RAM disk
|
creates a 4GB RAM disk
|
||||||
3. `color` to print colored text (see 3. in the Misc section):
|
3. `color` to print colored text (see 3. in the Misc section):
|
||||||
color red "This will be printed in red"
|
color $Red "This will be printed in red"
|
||||||
|
color $Yellow "This will be printed in red"
|
||||||
4. `mecp` to copy files back to the machine from wich you are ssh-ing.
|
4. `mecp` to copy files back to the machine from wich you are ssh-ing.
|
||||||
For this to work an ssh tunnel with Remoteforward is needed:
|
For this to work an ssh tunnel with Remoteforward is needed:
|
||||||
ssh -R 22:localhost:2222 YOURHOSTNAMEHERE
|
ssh -R 22:localhost:2222 YOURHOSTNAMEHERE
|
||||||
or specify this in ~/.ssh/config:
|
or specify this in ~/.ssh/config:
|
||||||
Host YOURHOSTNAMEHERE
|
Host YOURHOSTNAMEHERE
|
||||||
Remoteforward 2222 localhost:22
|
Remoteforward 2222 localhost:22
|
||||||
|
This can be enabled in ~/.ssh/config globally for all hosts by uncommenting the relevant `Host * Remoteforward`.
|
||||||
You might have to manually edit the username in the mecp definition in functions.sh if this is
|
You might have to manually edit the username in the mecp definition in functions.sh if this is
|
||||||
different between the two machines. mecp copies by default on the local machine on ~/Desktop/
|
different between the two machines. mecp copies by default on the local machine on ~/Desktop/
|
||||||
5. Many more. Type "list_functions" to list defined functions and a small description
|
5. Many more. Type "list_functions" to list defined functions and a small description
|
||||||
|
@ -53,14 +60,14 @@ creates a 4GB RAM disk
|
||||||
* (Optional: Compression, this should allow more responsive shells with slow connections,
|
* (Optional: Compression, this should allow more responsive shells with slow connections,
|
||||||
but will slow things down when copying large files. My suggestion is to have compression enabled
|
but will slow things down when copying large files. My suggestion is to have compression enabled
|
||||||
on a by-host basis in `~/.ssh/config`)
|
on a by-host basis in `~/.ssh/config`)
|
||||||
3. brethil.zsh-theme, theme for oh-my-zsh, installed in ~/.oh-my-zsh/themes/
|
3. brethil.zsh-theme, theme for oh-my-zsh, symlinked in ~/.oh-my-zsh/custom/themes
|
||||||
4. ~/.dotfiles_functions, ~/.dotfiles_aliases are sourced by this dotfiles, allowing for custom functions/aliases
|
4. ~/.dotfiles_functions, ~/.dotfiles_aliases are sourced by this dotfiles, allowing for custom functions/aliases
|
||||||
5. useful_commands contains a list of useful commands (the first rule of the tautology club...)
|
5. useful_commands contains a list of useful commands (the first rule of the tautology club...)
|
||||||
### Misc ###
|
### Misc ###
|
||||||
|
|
||||||
1. Colored output for `ls`/`grep`/`man`
|
1. Colored output for: `diff`, `configure`, `make`, `gcc`, `g`, `as`, `gas`, `ld`, `netstat`, `ping`, `traceroute`, `head`, `tail`, `dig`, `mount`, `ps`, `mtr`
|
||||||
2. Easy names for ANSI color escapes (Black, Red, Green, Yellow, Blue, Cyan, Purple, White, CLEAR),
|
2. Easy names for ANSI color escapes (Black, Red, Green, Yellow, Blue, Cyan, Purple, White, CLEAR),
|
||||||
for example:
|
for example:
|
||||||
`echo -e "${Green}This text will be green${CLEAR}"`
|
`echo -e "${Green}This text will be green${CLEAR}"`
|
||||||
will result in green text. Use `$CLEAR` to clear previous escale sequences add B before the variable
|
will result in green text. Use `$CLEAR` to clear previous escape sequences add B before the variable (check colors.sh)
|
||||||
name to use **bold** and U to underline (examples: $BRed, $UBlack for bold red and underlined black)
|
name to use **bold** and U to underline (examples: $BRed, $UBlack for bold red and underlined black)
|
||||||
|
|
35
aliases.sh
35
aliases.sh
|
@ -36,11 +36,10 @@ fi
|
||||||
alias bell='echo -en "\007"'
|
alias bell='echo -en "\007"'
|
||||||
|
|
||||||
alias grep="grep --color=auto"
|
alias grep="grep --color=auto"
|
||||||
|
|
||||||
##############
|
##############
|
||||||
## ls aliases
|
## ls aliases
|
||||||
############
|
############
|
||||||
|
|
||||||
|
|
||||||
# ls -al, only show files that start with a dot
|
# ls -al, only show files that start with a dot
|
||||||
alias lsdot="ls -al | awk '\$9 ~ /^\./ {print \$0}'"
|
alias lsdot="ls -al | awk '\$9 ~ /^\./ {print \$0}'"
|
||||||
|
|
||||||
|
@ -62,8 +61,8 @@ alias lsrt="ls -lrt | tail -10"
|
||||||
#### New features
|
#### New features
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
## List open connections (+c flag is to show command name with 15 characters (what the system provides))
|
## List open connections, TCP and UDP
|
||||||
alias listconnections="lsof +c 15 -r -i TCP -i UDP"
|
alias listconnections="lsof -n -i TCP -i UDP"
|
||||||
## Stress (run stress &>/dev/null &)
|
## Stress (run stress &>/dev/null &)
|
||||||
alias stress='yes >> /dev/null'
|
alias stress='yes >> /dev/null'
|
||||||
|
|
||||||
|
@ -76,12 +75,30 @@ alias mdiff="mate -t source.diff"
|
||||||
# define ssh without controlmaster
|
# define ssh without controlmaster
|
||||||
alias ssh1="ssh -o ControlMaster=no"
|
alias ssh1="ssh -o ControlMaster=no"
|
||||||
|
|
||||||
# Colorizing aliases (using grc)
|
|
||||||
alias ps="grc ps"
|
|
||||||
alias ping="grc ping"
|
|
||||||
alias traceroute="grc traceroute"
|
|
||||||
alias mtr="grc mtr"
|
|
||||||
|
|
||||||
|
# Some colorizing options for grc
|
||||||
|
GRC=`which grc`
|
||||||
|
if [ "$TERM" != dumb ] && [ -n "$GRC" ]
|
||||||
|
then
|
||||||
|
alias colourify="$GRC -es --colour=auto"
|
||||||
|
alias configure='colourify ./configure'
|
||||||
|
alias diff='colourify diff'
|
||||||
|
alias make='colourify make'
|
||||||
|
alias gcc='colourify gcc'
|
||||||
|
alias g++='colourify g++'
|
||||||
|
alias as='colourify as'
|
||||||
|
alias gas='colourify gas'
|
||||||
|
alias ld='colourify ld'
|
||||||
|
alias netstat='colourify netstat'
|
||||||
|
alias ping='colourify ping'
|
||||||
|
alias traceroute='colourify /usr/sbin/traceroute'
|
||||||
|
alias head='colourify head'
|
||||||
|
alias tail='colourify tail'
|
||||||
|
alias dig='colourify dig'
|
||||||
|
alias mount='colourify mount'
|
||||||
|
alias ps='colourify ps'
|
||||||
|
alias mtr='colourify mtr'
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -f ~/.dotfiles_aliases ]];
|
if [[ -f ~/.dotfiles_aliases ]];
|
||||||
then
|
then
|
||||||
|
|
|
@ -1,57 +1,37 @@
|
||||||
if [[ "$SHELL" == *"bash" ]]; then
|
# Check for update, set DISABLE_UPDATE_PROMPT=yes to disable the prompt and automatically update
|
||||||
alias resource="source $HOME/.bash_profile"
|
env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $DOTFILES/check_for_update.sh
|
||||||
alias esource="mate -t source.shell $HOME/.bash_profile"
|
|
||||||
elif [[ "$SHELL" == *"/zsh" ]]; then
|
# oh-my-zsh plugins (some of these have to be installed by running install.sh or install_zsh_plugins, found in install.sh)
|
||||||
alias resource="source $HOME/.zshrc"
|
shared_plugins=(git common-aliases fast-syntax-highlighting zsh-autosuggestions colored-man-pages zsh-navigation-tools zsh_reload cheat)
|
||||||
## zsh plugins, these can be installed easily with zplug
|
|
||||||
#if [[ "$(uname)" == "Darwin" ]]; then
|
uname=$(uname -a)
|
||||||
# plugins=(git common-aliases osx macports textmate anybar)
|
if [[ $uname == *"Darwin"* ]]; then
|
||||||
#else
|
os_extra=(osx brew)
|
||||||
# plugins=(git common-aliases)
|
elif [[ $uname == *"ARCH"* ]]; then
|
||||||
#fi
|
os_extra=(archlinux)
|
||||||
|
elif [[ $uname == *"Debian"* ]]; then
|
||||||
alias esource="mate -t source.shell $HOME/.zshrc"
|
os_extra=(debian)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
alias dotedit="mate -t source.shell $DOTFILES/brethil_dotfile.sh"
|
plugins=($shared_plugins $os_extra)
|
||||||
alias funedit="mate -t source.shell $DOTFILES/functions.sh"
|
|
||||||
alias aledit="mate -t source.shell $DOTFILES/aliases.sh"
|
alias resource="source $HOME/.zshrc"
|
||||||
|
alias dotedit="$EDITOR $DOTFILES/brethil_dotfile.sh"
|
||||||
|
alias funedit="$EDITOR $DOTFILES/functions.sh"
|
||||||
|
alias aledit="$EDITOR $DOTFILES/aliases.sh"
|
||||||
|
|
||||||
# Extras
|
# Extras
|
||||||
functions_file=$DOTFILES/functions.sh # Function definitions
|
functions_file=$DOTFILES/functions.sh # Function definitions
|
||||||
aliases_file=$DOTFILES/aliases.sh # Aliases definitions
|
aliases_file=$DOTFILES/aliases.sh # Aliases definitions
|
||||||
colors_file=$DOTFILES/colors.sh # Colors definitions
|
colors_file=$DOTFILES/colors.sh # Colors definitions
|
||||||
|
|
||||||
|
|
||||||
# Source extras
|
# Source extras
|
||||||
if [ -f $functions_file ]; then source $functions_file; fi
|
if [ -f $functions_file ]; then source $functions_file; fi
|
||||||
if [ -f $aliases_file ]; then source $aliases_file; fi
|
if [ -f $aliases_file ]; then source $aliases_file; fi
|
||||||
if [ -f $colors_file ]; then source $colors_file; fi
|
if [ -f $colors_file ]; then source $colors_file; fi
|
||||||
|
|
||||||
########################
|
export EDITOR="vim"
|
||||||
## Make prompt prettier
|
|
||||||
######################
|
|
||||||
if [[ -e $BASH ]]; then
|
|
||||||
export PROMPT_COMMAND='echo -ne "\033]0;${PWD/#$HOME/~}\007"'
|
|
||||||
## This prompt only contains date, username and path, prints a red 'x' when a commands fails
|
|
||||||
#export PS1='[\t][:\w]$(if [[ $? != 0 ]]; then printf "[\[\e[31m\]✗\[\e[0m\]] "; else printf " "; fi)'
|
|
||||||
promptred="\[\033[1;31m\]"
|
|
||||||
promptgreen="\[\033[1;32m\]"
|
|
||||||
promptclear="\[\033[m\]"
|
|
||||||
export PS1="[\t][$promptred\h$promptclear][:$promtgreen\w$promptclear] "
|
|
||||||
|
|
||||||
### Other prompt choices:
|
|
||||||
## This prompt includes includes host name
|
|
||||||
# export PS1='[\t][\h][\u:\w] '
|
|
||||||
## This prompt only includes username, date and path
|
|
||||||
#export PS1='[\t][\u:\w] '
|
|
||||||
fi
|
|
||||||
|
|
||||||
export EDITOR="mate -w"
|
|
||||||
|
|
||||||
### SETUP PATHS ####
|
### SETUP PATHS ####
|
||||||
export PATH=$PATH:$HOME/bin/
|
export PATH=$PATH:$HOME/bin
|
||||||
export PYTHONPATH=$PYTHONPATH:$HOME/python/:$HOME/bin
|
#export PYTHONPATH=$PYTHONPATH:$HOME/python/:$HOME/bin
|
||||||
|
|
||||||
## One can also use most pager instead of less to visualize man pages
|
|
||||||
#export PAGER="most"
|
|
63
check_for_update.sh
Executable file
63
check_for_update.sh
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
#
|
||||||
|
# brethil, brutally copied form https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/check_for_upgrade.sh
|
||||||
|
# 14 July 2017
|
||||||
|
|
||||||
|
zmodload zsh/datetime
|
||||||
|
|
||||||
|
function _current_epoch() {
|
||||||
|
echo $(( $EPOCHSECONDS / 60 / 60 / 24 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
function _update_dotfiles_update() {
|
||||||
|
echo "LAST_EPOCH=$(_current_epoch)" >! ~/.dotfiles-update
|
||||||
|
}
|
||||||
|
|
||||||
|
function _upgrade_dotfiles() {
|
||||||
|
(cd $DOTFILES; git pull)
|
||||||
|
# update the zsh file
|
||||||
|
_update_dotfiles_update
|
||||||
|
}
|
||||||
|
|
||||||
|
epoch_target=$UPDATE_ZSH_DAYS
|
||||||
|
if [[ -z "$epoch_target" ]]; then
|
||||||
|
# Default to old behavior
|
||||||
|
epoch_target=13
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Cancel upgrade if the current user doesn't have write permissions for the
|
||||||
|
# oh-my-zsh directory.
|
||||||
|
[[ -w "$ZSH" ]] || return 0
|
||||||
|
|
||||||
|
# Cancel upgrade if git is unavailable on the system
|
||||||
|
whence git >/dev/null || return 0
|
||||||
|
|
||||||
|
if mkdir "$DOTFILES/log/update.lock" 2>/dev/null; then
|
||||||
|
if [ -f ~/.dotfiles-update ]; then
|
||||||
|
. ~/.dotfiles-update
|
||||||
|
|
||||||
|
if [[ -z "$LAST_EPOCH" ]]; then
|
||||||
|
_update_dotfiles_update && return 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
|
||||||
|
if [ $epoch_diff -gt $epoch_target ]; then
|
||||||
|
if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then
|
||||||
|
_upgrade_dotfiles
|
||||||
|
else
|
||||||
|
echo "[brethil dotfiles] Would you like to check for updates? [Y/n]: \c"
|
||||||
|
read line
|
||||||
|
if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
|
||||||
|
_upgrade_dotfiles
|
||||||
|
else
|
||||||
|
_update_dotfiles_update
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# create the dotfiles file
|
||||||
|
_update_dotfiles_update
|
||||||
|
fi
|
||||||
|
|
||||||
|
rmdir $DOTFILES/log/update.lock
|
||||||
|
fi
|
|
@ -73,14 +73,13 @@ On_ICyan='\e[0;106m' # Cyan
|
||||||
On_IWhite='\e[0;107m' # White
|
On_IWhite='\e[0;107m' # White
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# ANSI COLOR ESCAPES 2
|
# ANSI COLOR ESCAPES 2
|
||||||
## Clear all previous sequences
|
## Clear all previous sequences
|
||||||
# Bold text
|
# Bold text
|
||||||
BOLD="\e[1m"
|
BOLD="\e[1m"
|
||||||
# Colors: Black, Blue, Green, Cyan, Red, Purple, Brown, LightGray
|
# Colors: Black, Blue, Green, Cyan, Red, Purple, Brown, LightGray
|
||||||
BLACK="\e[30m"; BLUE="\e[34m"; GREEN="\e[32m"; CYAN="\e[36m";
|
BLACK="\e[30m"; BLUE="\e[34m"; GREEN="\e[32m"; CYAN="\e[36m";
|
||||||
RED="\e\[31m"; PURPLE="\e[35m"; BROWN="\e[33m"; LIGHTGRAY="\e[37m";
|
RED="\e[31m"; PURPLE="\e[35m"; BROWN="\e[33m"; LIGHTGRAY="\e[37m";
|
||||||
DARKGRAY="\e[30m"; LIGHTBLUE="\e[34m"; LIGHTGREEN="\e[32m";
|
DARKGRAY="\e[30m"; LIGHTBLUE="\e[34m"; LIGHTGREEN="\e[32m";
|
||||||
LIGHTCYAN="\e[36m"; LIGHTRED="\e[31m"; LIGHTPURPLE="\e[35m";
|
LIGHTCYAN="\e[36m"; LIGHTRED="\e[31m"; LIGHTPURPLE="\e[35m";
|
||||||
YELLOW="\e[33m"; WHITE="\e[37m"
|
YELLOW="\e[33m"; WHITE="\e[37m"
|
||||||
|
|
177
functions.sh
177
functions.sh
|
@ -1,31 +1,24 @@
|
||||||
###########################
|
###########################
|
||||||
#### Function Definitions #
|
#### Function Definitions #
|
||||||
###########################
|
###########################
|
||||||
|
## Selfupdate
|
||||||
|
function dotfiles_selfupdate
|
||||||
|
{
|
||||||
|
(cd $DOTFILES; git pull)
|
||||||
|
}
|
||||||
|
|
||||||
|
## get cheat sheets for commands from cheat.sh. Usage: cheat commandname
|
||||||
|
function cheat
|
||||||
|
{
|
||||||
|
curl cheat.sh/$1
|
||||||
|
}
|
||||||
## Simple calculator. Usage: calc 1+1, calc 5/7, calc "sqrt(2)"
|
## Simple calculator. Usage: calc 1+1, calc 5/7, calc "sqrt(2)"
|
||||||
function calc {
|
function calc
|
||||||
awk "BEGIN { print "$*" }"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
## Open Man in separate (good looking) window
|
|
||||||
function nman
|
|
||||||
{
|
{
|
||||||
if [ $# -eq 1 ] ;
|
awk "BEGIN { print "$*" }"
|
||||||
then open x-man-page://$1 ;
|
|
||||||
elif [ $# -eq 2 ] ;
|
|
||||||
then open x-man-page://$1/$2 ;
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
## Open a pdf version of the man in Preview
|
## Make new directory and cd to that directory. Usage: mcd newfolder
|
||||||
function man2pdf
|
|
||||||
{
|
|
||||||
man -t "$1" | open -f -a Preview
|
|
||||||
}
|
|
||||||
|
|
||||||
## Make new directory and cd to that directory
|
|
||||||
function mcd
|
function mcd
|
||||||
{
|
{
|
||||||
mkdir -p $1
|
mkdir -p $1
|
||||||
|
@ -47,36 +40,38 @@ function color
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## These functions return a colored version of the input string
|
## These functions return a colored version of the input string. Usage: red "string"
|
||||||
function red
|
function red
|
||||||
{
|
{
|
||||||
echo -e "$RED$@$CLEAR"
|
echo -e "$Red$@$CLEAR"
|
||||||
}
|
}
|
||||||
function green {
|
function green
|
||||||
echo -e "$GREEN$@$CLEAR"
|
{
|
||||||
|
echo -e "$Green$@$CLEAR"
|
||||||
}
|
}
|
||||||
function blue {
|
function blue
|
||||||
echo -e "$BLUE$1$CLEAR"
|
{
|
||||||
|
echo -e "$Blue@$CLEAR"
|
||||||
}
|
}
|
||||||
|
|
||||||
## Flashes the screen until user presses a key
|
## Flashes the screen until user presses a key
|
||||||
function flasher
|
function flasher
|
||||||
{
|
{
|
||||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n1 -t1 && break; done;
|
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||||
}
|
}
|
||||||
|
|
||||||
## Beep until user presses a key
|
## Beep until user presses a key
|
||||||
function beeper
|
function beeper
|
||||||
{
|
{
|
||||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n1 -t1 && break; done;
|
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||||
}
|
}
|
||||||
|
|
||||||
## Search youtube for string ($1) and play video
|
## Search youtube for string ($1) and play video (uses mplayer)
|
||||||
function pyt
|
function pyt
|
||||||
{
|
{
|
||||||
echo 'https://www.youtube.com/results?search_query='"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))"; id=$(curl -s 'https://www.youtube.com/results?search_query='"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))" | grep -om3 '"[[:alnum:]]\{11\}"' | awk NR==3 | tr -d \"); url='https://www.youtube.com/watch?v='"$id"; echo -e "URL:\t$url"; youtube-dl -q $url -o - | mplayer -vo corevideo -really-quiet /dev/fd/3 3<&0 </dev/tty;
|
echo 'https://www.youtube.com/results?search_query='"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))"; id=$(curl -s 'https://www.youtube.com/results?search_query='"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))" | grep -om3 '"[[:alnum:]]\{11\}"' | awk NR==3 | tr -d \"); url='https://www.youtube.com/watch?v='"$id"; echo -e "URL:\t$url"; youtube-dl -q $url -o - | mplayer -vo corevideo -really-quiet /dev/fd/3 3<&0 </dev/tty;
|
||||||
}
|
}
|
||||||
## Same as above, only play music
|
## Same as above, only play music (uses mplayer)
|
||||||
function pmusic
|
function pmusic
|
||||||
{
|
{
|
||||||
echo 'https://www.youtube.com/results?search_query=HD%20'"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))"; id=$(curl -s 'https://www.youtube.com/results?search_query='HD%20"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))" | grep -om3 '"[[:alnum:]]\{11\}"' | awk NR==3 | tr -d \"); url='https://www.youtube.com/watch?v='"$id"; echo -e "URL:\t$url"; youtube-dl -q $url -o - | mplayer -vo corevideo -really-quiet /dev/fd/3 3<&0 </dev/tty;
|
echo 'https://www.youtube.com/results?search_query=HD%20'"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))"; id=$(curl -s 'https://www.youtube.com/results?search_query='HD%20"$(sed 's/ /%20/g' <<< $(tr '\' '+' <<< "$@"))" | grep -om3 '"[[:alnum:]]\{11\}"' | awk NR==3 | tr -d \"); url='https://www.youtube.com/watch?v='"$id"; echo -e "URL:\t$url"; youtube-dl -q $url -o - | mplayer -vo corevideo -really-quiet /dev/fd/3 3<&0 </dev/tty;
|
||||||
|
@ -99,37 +94,36 @@ function httpserver
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
## Upload something using the transfer.sh service
|
## Upload something using the transfer.sh service. Usage: transfer filename
|
||||||
function transfer
|
function transfer
|
||||||
{
|
{
|
||||||
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
|
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
|
||||||
out=$(curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile")
|
out=$(curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile")
|
||||||
echo -e "Done, file at:\t$out"
|
echo -e "Done, file at:\t$out"
|
||||||
echo "$out" | pbcopy
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
|
echo "$out" | pbcopy
|
||||||
|
else
|
||||||
|
echo "$out"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## List defined functions in $DOTFILES/functions.sh
|
## If connecting through ssh and reverse forwarding port 2222 (ssh -R 2222:localhost:22 ), this function allows to copy the files back to the machine one is connecting from by typing 'mecp filename' (configure the username for "localhost" in ~/.ssh/config or add an username)
|
||||||
function list_functions
|
|
||||||
{
|
|
||||||
cat $DOTFILES/functions.sh | grep --color=no -A 1 '^## ' | sed -E 's/function (.*)/\1()/g'
|
|
||||||
}
|
|
||||||
|
|
||||||
# If connecting through ssh and reverse forwarding port 2222 (ssh -R 2222:localhost:22 ), this function allows to copy the files back to the machine one is connecting from by typing 'mecp filename' (configure the username for "localhost" in ~/.ssh/config or add an username)
|
|
||||||
function mecp
|
function mecp
|
||||||
{
|
{
|
||||||
rsync -r -P -e "ssh -p 2222" -R "$@" localhost:~/Desktop/
|
rsync -r -P -e "ssh -p 2222" -R "$@" localhost:~/Desktop/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# generate a password using pwgen, generate_password 20 generates a 20 characters long password
|
## generate a password using pwgen, generate_password 20 generates a 20 characters long password
|
||||||
function generate_password
|
function generate_password
|
||||||
{
|
{
|
||||||
pwgen -1sycn $1
|
pwgen -1sycn $1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate a password from dev urandom using only printable characters
|
## Generate a password from dev urandom using only printable characters
|
||||||
function genpwd {
|
function genpwd
|
||||||
if [[ -e $1 ]]; then
|
{
|
||||||
|
if [[ $1 ]]; then
|
||||||
strlen=$1
|
strlen=$1
|
||||||
else
|
else
|
||||||
strlen=32
|
strlen=32
|
||||||
|
@ -139,53 +133,82 @@ function genpwd {
|
||||||
|
|
||||||
|
|
||||||
if [[ "$(uname)" == "Darwin" ]]; then
|
if [[ "$(uname)" == "Darwin" ]]; then
|
||||||
# Copy output of previous command to termbin.com (command line pastebin) and put in in clipboard
|
## Copy output of previous command to termbin.com (command line pastebin) and put in in clipboard
|
||||||
function termbin {
|
function termbin
|
||||||
|
{
|
||||||
nc termbin.com 9999 | pbcopy && echo -n "$(pbpaste) --> in clipboard"
|
nc termbin.com 9999 | pbcopy && echo -n "$(pbpaste) --> in clipboard"
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
function termbin {
|
## Copy output of previous command to termbin.com (command line pastebin)
|
||||||
|
function termbin
|
||||||
|
{
|
||||||
nc termbin 9999
|
nc termbin 9999
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## List defined functions in $DOTFILES/functions.sh
|
||||||
|
function list_functions
|
||||||
|
{
|
||||||
|
cat $DOTFILES/functions.sh | grep --color=no -A 1 '^##' | sed -E 's/function (.*)/\1/g'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
## MAC SPECIFIC #
|
## MAC SPECIFIC #
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
if [[ "$(uname)" == "Darwin" ]];
|
if [[ "$(uname)" == "Darwin" ]];
|
||||||
then
|
then
|
||||||
## Create a RAM disk. Default size 1GB. If supplied, first argument defines the RAM disk size in GB
|
## Create a RAM disk. Default size 1GB. If supplied, first argument defines the RAM disk size in GB
|
||||||
function ramdisk {
|
function ramdisk
|
||||||
if [[ -e $1 ]];
|
{
|
||||||
then
|
if [[ -e $1 ]];
|
||||||
sizeingb=$1
|
then
|
||||||
else
|
sizeingb=$1
|
||||||
sizeingb=1
|
else
|
||||||
fi
|
sizeingb=1
|
||||||
|
fi
|
||||||
# Numsectors is size in bytes / 512 (sector size in bytes)
|
|
||||||
name='RAM_disk'
|
# Numsectors is size in bytes / 512 (sector size in bytes)
|
||||||
sizeinbytes=$(($sizeingb*1000**3))
|
name='RAM_disk'
|
||||||
NUMSECTORS=$(($sizeinbytes/512))
|
sizeinbytes=$(($sizeingb*1000**3))
|
||||||
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
NUMSECTORS=$(($sizeinbytes/512))
|
||||||
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
||||||
mydev=$(echo "$mydev"| xargs echo)
|
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
||||||
newfs_hfs $mydev
|
mydev=$(echo "$mydev"| xargs echo)
|
||||||
mkdir -p "/tmp/$name"
|
newfs_hfs $mydev
|
||||||
mount -t hfs $mydev "/tmp/$name"
|
mkdir -p "/tmp/$name"
|
||||||
echo "RAM Disk mounted: /tmp/$name"
|
mount -t hfs $mydev "/tmp/$name"
|
||||||
echo "To eject (destroy) RAM disk, use:"
|
echo "RAM Disk mounted: /tmp/$name"
|
||||||
echo " $ diskutil eject $mydev"
|
echo "To eject (destroy) RAM disk, use:"
|
||||||
}
|
echo " $ diskutil eject $mydev"
|
||||||
|
}
|
||||||
# Anybar support https://github.com/tonsky/AnyBar
|
|
||||||
function anybar { echo -n $1 | nc -4u -w0 localhost ${2:-1738}; }
|
## Anybar support https://github.com/tonsky/AnyBar
|
||||||
|
function anybar
|
||||||
fi
|
{
|
||||||
|
echo -n $1 | nc -4u -w0 localhost ${2:-1738};
|
||||||
|
}
|
||||||
|
|
||||||
|
## Open a pdf version of the man in Preview
|
||||||
|
function man2pdf
|
||||||
|
{
|
||||||
|
man -t "$1" | open -f -a Preview
|
||||||
|
}
|
||||||
|
|
||||||
|
## Open Man in separate (different-looking) window
|
||||||
|
function nman
|
||||||
|
{
|
||||||
|
if [ $# -eq 1 ] ;
|
||||||
|
then open x-man-page://$1 ;
|
||||||
|
elif [ $# -eq 2 ] ;
|
||||||
|
then open x-man-page://$1/$2 ;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
fi # end of mac-specific functions
|
||||||
|
|
||||||
|
|
||||||
if [[ -f ~/.dotfiles_functions ]];
|
if [[ -f ~/.dotfiles_functions ]];
|
||||||
then
|
then
|
||||||
source ~/.dotfiles_functions
|
source ~/.dotfiles_functions
|
||||||
fi
|
fi
|
||||||
|
|
227
install.sh
227
install.sh
|
@ -5,38 +5,45 @@
|
||||||
# Get the location for the dotfiles
|
# Get the location for the dotfiles
|
||||||
DOTFILES=$PWD
|
DOTFILES=$PWD
|
||||||
|
|
||||||
echo -e "\n\n# Beginning of brethil's dotfiles:" >> ~/.zshrc
|
ZSHTMP="$HOME/.zshrctmp"
|
||||||
echo "DOTFILES=$DOTFILES" >> ~/.zshrc
|
echo -e "\n\n# brethil's dotfiles:" >> $ZSHTMP
|
||||||
echo "source \$DOTFILES/brethil_dotfile.sh" >> ~/.zshrc
|
echo "DOTFILES=$DOTFILES" >> $ZSHTMP
|
||||||
|
echo "source \$DOTFILES/brethil_dotfile.sh" >> $ZSHTMP
|
||||||
|
echo -e "# End of brethil's dotfiles\n\n"
|
||||||
function install_rmate {
|
function install_rmate {
|
||||||
## Ruby version:
|
# Install python version of the textmate rmate remote (from github)
|
||||||
#curl -Lo ~/bin/rmate https://raw.github.com/textmate/rmate/master/bin/rmate
|
|
||||||
## Python version:
|
|
||||||
echo "Installing rmate (python)..."
|
|
||||||
if [[ $(whoami) == "root" ]]; then
|
if [[ $(whoami) == "root" ]]; then
|
||||||
destpath="/usr/bin"
|
destpath="/usr/bin"
|
||||||
else
|
else
|
||||||
destpath="$HOME/bin"
|
destpath="$HOME/bin"
|
||||||
fi
|
fi
|
||||||
curl -sL https://raw.githubusercontent.com/sclukey/rmate-python/master/bin/rmate >> $destpath/rmate
|
if [[ -f $destpath/rmate ]]; then
|
||||||
chmod a+x $destpath/rmate
|
echo "rmate already exists: not installed"
|
||||||
ln -s $destpath/rmate $destpath/mate || "Could not create symbolic link to $destpath/mate (already exists?)"
|
return -1
|
||||||
echo "Installed rmate (and mate symlink) in $destpath"
|
else
|
||||||
|
curl -sL https://raw.githubusercontent.com/sclukey/rmate-python/master/bin/rmate > $destpath/rmate
|
||||||
|
chmod a+x $destpath/rmate
|
||||||
|
ln -s $destpath/rmate $destpath/mate || "Could not create symbolic link to $destpath/mate (already exists?)"
|
||||||
|
echo "Installed rmate (and mate symlink) in $destpath"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function install_vimrc {
|
function install_vimrc {
|
||||||
git clone https://github.com/amix/vimrc.git $HOME/.vim_runtime
|
# Install vimrc from github.com/amix/vimrc
|
||||||
sh $HOME/.vim_runtime/install_awesome_vimrc.sh
|
git clone https://github.com/amix/vimrc.git $HOME/.vim_runtime && sh $HOME/.vim_runtime/install_awesome_vimrc.sh || return -1
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_zsh_plugins {
|
function install_zsh_plugins {
|
||||||
# Install fast-syntax-highlighting zsh-autosuggestions
|
# Install fast-syntax-highlighting (git: zdharma), zsh-autosuggestions (git:zsh-users)
|
||||||
ZSH_PLUGINS="$HOME/.oh-my-zsh/custom/plugins"
|
ZSH_PLUGINS="$HOME/.oh-my-zsh/custom/plugins"
|
||||||
git clone https://github.com/zdharma/fast-syntax-highlighting.git ${ZSH_PLUGINS}/fast-syntax-highlighting
|
git clone https://github.com/zdharma/fast-syntax-highlighting.git ${ZSH_PLUGINS}/fast-syntax-highlighting || error=true
|
||||||
git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_PLUGINS}/zsh-autosuggestions
|
git clone git://github.com/zsh-users/zsh-autosuggestions ${ZSH_PLUGINS}/zsh-autosuggestions || error=true
|
||||||
|
if [[ $error ]]; then
|
||||||
|
return -1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add an ssh config file with:
|
# Add an ssh config file with:
|
||||||
|
@ -47,14 +54,22 @@ function create_ssh_config {
|
||||||
|
|
||||||
ssh_config="$HOME/.ssh/config"
|
ssh_config="$HOME/.ssh/config"
|
||||||
|
|
||||||
if [ ! -d $HOME/.ssh/id_rsa ]; then
|
if [ ! -f $HOME/.ssh/id_rsa ]; then
|
||||||
ssh-keygen -t rsa -b 4096
|
echo "Creating ssh key (4096bit)..."
|
||||||
|
|
||||||
|
echo "Enter ssh-key comment (leave empty for default: user@host)"
|
||||||
|
read comment
|
||||||
|
if [[ $comment ]];
|
||||||
|
ssh-keygen -t rsa -b 4096 -C $comment
|
||||||
|
else
|
||||||
|
ssh-keygen -t rsa -b 4096
|
||||||
|
done
|
||||||
|
# fix permissions
|
||||||
chmod 0700 "$HOME/.ssh"
|
chmod 0700 "$HOME/.ssh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f $ssh_config ]]; then
|
if [[ -f $ssh_config ]]; then
|
||||||
while [ "$modifyssh" != "y" ] && [ "$modifyssh" != "n" ]
|
until [[ $modifyssh == "y" ]] or [[ $modifyssh == "n" ]]; do
|
||||||
do
|
|
||||||
echo "Do you want to modify the existing ssh config? (New values will be appended) (y/n)"
|
echo "Do you want to modify the existing ssh config? (New values will be appended) (y/n)"
|
||||||
read modifyssh
|
read modifyssh
|
||||||
done
|
done
|
||||||
|
@ -62,118 +77,141 @@ function create_ssh_config {
|
||||||
|
|
||||||
if [[ "$modifyssh" != "n" ]]
|
if [[ "$modifyssh" != "n" ]]
|
||||||
then
|
then
|
||||||
echo "# brethil's dotfiles setup start" >> $ssh_config
|
echo "# brethil's dotfiles setup start" >> $ssh_config
|
||||||
echo 'TCPKeepAlive=yes' >> $ssh_config
|
echo 'TCPKeepAlive=yes' >> $ssh_config
|
||||||
echo 'ServerAliveCountMax=6' >> $ssh_config
|
echo 'ServerAliveCountMax=6' >> $ssh_config
|
||||||
|
|
||||||
## Compression will slow things down when copying large files, but improve
|
echo "## Uncomment to enable compression for all ssh sessions" >> $ssh_config
|
||||||
## speed if only using a shell, my reccommendation is to enable it on a by-host
|
echo '#Compression=yes' >> $ssh_config
|
||||||
## basis in ~/.ssh/config
|
|
||||||
#echo ' Compression=yes' >> $ssh_config
|
|
||||||
|
|
||||||
#echo 'ControlMaster auto' >> $ssh_config
|
echo '## Uncomment the following to enable ssh ControlMaster and ssh session persistence' >> $ssh_config
|
||||||
#echo 'ControlPath /tmp/%r@%h:%p' >> $ssh_config
|
echo '#ControlMaster auto' >> $ssh_config
|
||||||
#echo 'ControlPersist yes' >> $ssh_config
|
echo '#ControlPath /tmp/%r@%h:%p' >> $ssh_config
|
||||||
echo 'Host *' >> $ssh_config
|
echo '#ControlPersist yes' >> $ssh_config
|
||||||
echo 'ServerAliveInterval 300' >> $ssh_config
|
echo 'Host *' >> $ssh_config
|
||||||
echo '# end of brethil dotfiles setup #' >> $ssh_config
|
echo 'ServerAliveInterval 300' >> $ssh_config
|
||||||
|
echo '## Enable the following if you want to use the rmate textmate remote' >> $ssh_config
|
||||||
|
echo "#Host *" >> $ssh_config
|
||||||
|
echo "#RemoteForward 52698 localhost:52698" >> $ssh_config
|
||||||
|
echo '## Enable the following if you want to use a reverse ssh tunnel to use mecp command on remote hosts' >> $ssh_config
|
||||||
|
echo "Host *" >> $ssh_config
|
||||||
|
echo "Remoteforward 2222 localhost:22" >> $ssh_config
|
||||||
|
echo '# end of brethil dotfiles setup #' >> $ssh_config
|
||||||
|
|
||||||
## Enable the following if you want to use the rmate textmate remote
|
echo ".ssh/ssh_config configured check it to enable custom options:"
|
||||||
#echo "Host *" >> $ssh_config
|
echo "- Compression"
|
||||||
#echo "RemoteForward 52698 localhost:52698" >> $ssh_config
|
echo "- Remote forwarding port 52698->52698 (Textmate rmate remote)"
|
||||||
## Enable the following if you want to use a reverse ssh tunnel (mecp)
|
echo "- Remote forwarding remote:2222->localhost:22 (mecp)"
|
||||||
#echo "Host *" >> $ssh_config
|
|
||||||
#echo "Remoteforward 2222 localhost:22" >> $ssh_config
|
|
||||||
|
|
||||||
#
|
|
||||||
echo ".ssh folder configured, enabled ControlMaster for all connections."
|
|
||||||
echo "Compression disabled, enable by uncommenting 'Compression' in ~/.ssh/config"
|
|
||||||
echo "Remote forwarding port 52698->52698 (Textmate) and port 2222->22 (mecp) for all hosts."
|
|
||||||
else
|
else
|
||||||
echo "Did not modify $ssh_config."
|
echo "Did not modify $ssh_config."
|
||||||
fi
|
fi
|
||||||
echo "# End of ssh config."
|
echo "# End of ssh config."
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run after first copying to a remote machine
|
# First setup
|
||||||
function brethil_dotfiles_setup {
|
function brethil_dotfiles_setup {
|
||||||
bin="$HOME/bin/"
|
bin="$HOME/bin"
|
||||||
#python="$HOME/python"
|
|
||||||
projects="$HOME/projects"
|
projects="$HOME/projects"
|
||||||
git="$HOME/git"
|
git="$HOME/git"
|
||||||
mkdir -p "$bin"
|
mkdir -p "$bin" "$projects" "$git" && echo "Created dirs $bin, $projects, $git"
|
||||||
mkdir -p "$projects"
|
|
||||||
mkdir -p "$git"
|
|
||||||
|
|
||||||
|
|
||||||
echo "Created dirs $bin, $projects, $git"
|
|
||||||
|
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
# zsh
|
# zsh
|
||||||
# byobu: configuration/wrapper for tmux
|
|
||||||
# grc: generic colourizer, colors output of any command
|
# grc: generic colourizer, colors output of any command
|
||||||
|
# ccze: similar to the above
|
||||||
|
# byobu: configuration/wrapper for tmux
|
||||||
# bmon: bandwidth monitor, monitors bandwith usage, shows graph
|
# bmon: bandwidth monitor, monitors bandwith usage, shows graph
|
||||||
# mtr: mytraceroute, traceroute tool
|
# mtr: mytraceroute, traceroute tool
|
||||||
# pv: pipe view, monitor the progress of data through a pipe
|
# pv: pipe view, monitor the progress of data through a pipe
|
||||||
# byobu: tmux wrapper
|
# byobu: tmux wrapper
|
||||||
packages="zsh git grc bmon mtr pv tmux byobu"
|
packages="zsh git grc ccze bmon mtr pv tmux byobu"
|
||||||
|
|
||||||
# Check if running as root, if not, quit.
|
# Check if running as root, if try using sudo to install packages.
|
||||||
if [[ ! $(id -g) == 0 ]]; then
|
# If sudo is not installed, launch a shell to try and install it
|
||||||
echo "This has to be run as root to install new software from the repos. Quitting..."
|
if [[ $(id -u) != 0 ]]; then
|
||||||
exit 0
|
if [[ ! -f $(which sudo) ]] ; then
|
||||||
|
unset yn
|
||||||
|
until [[ $yn == "y" || $yn == "n" ]]; do
|
||||||
|
echo "Cannot install new packages without root access. Do you want to try to manually install sudo? (yn) "
|
||||||
|
read yn
|
||||||
|
done
|
||||||
|
if [[ $yn == "y" ]]; then
|
||||||
|
echo "Launching an interactive shell. Type exit after installing sudo."
|
||||||
|
/bin/bash
|
||||||
|
else
|
||||||
|
echo "Quitting."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
else [[ -f $(which sudo) ]]; then
|
||||||
|
sudo="sudo "
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $(which apt-get ) ]]; then
|
if [[ $(which apt-get ) ]]; then
|
||||||
install_command="apt-get install"
|
install_command="${sudo}apt-get install"
|
||||||
elif [[ $(which pacman) ]]; then
|
elif [[ $(which pacman) ]]; then
|
||||||
install_command="pacman -Sy"
|
install_command="${sudo}pacman -Sy"
|
||||||
elif [[ $(which yum) ]]; then
|
elif [[ $(which yum) ]]; then
|
||||||
install_command="yum"
|
install_command="${sudo}yum"
|
||||||
elif [[ $(which port) ]]; then
|
elif [[ $(which port) ]]; then
|
||||||
install_command="port install"
|
install_command="${sudo}port install"
|
||||||
elif [[ $(which brew) ]]; then
|
elif [[ $(which brew) ]]; then
|
||||||
install_command="brew install"
|
install_command="${sudo}brew install"
|
||||||
else
|
else
|
||||||
echo "Could not install required packages"
|
echo "I do not know how to install the required packages. Quitting."
|
||||||
error=true
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! $error ]]; then
|
$install_command $packages
|
||||||
$install_command $packages
|
# Install oh-my-zsh
|
||||||
# Install oh-my-zsh
|
echo "Installing oh-my-zsh..."
|
||||||
echo "Installing oh-my-zsh..."
|
sh -c "$(curl -sL zsh.dioporc.one)"
|
||||||
sh -c "$(curl -sL zsh.dioporc.one)"
|
|
||||||
|
# oh-my-zsh's zshrc has been installed, prepend the dotfiles setup to it
|
||||||
## Fix scrolling in byobu
|
cat $HOME/.zshrc >> $ZSHTMP
|
||||||
|
mv $ZSHTMP $HOME/.zshrc
|
||||||
|
|
||||||
|
# Increase history size
|
||||||
|
echo "export HISTSIZE=100000" >> $HOME/.zshrc
|
||||||
|
|
||||||
|
## Fix scrolling in byobu
|
||||||
|
if [[ $(uname) == "Darwin" ]]; then
|
||||||
|
sed -i '' 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/share/byobu/profiles/tmux
|
||||||
|
else
|
||||||
sed -i 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/share/byobu/profiles/tmux
|
sed -i 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/share/byobu/profiles/tmux
|
||||||
|
|
||||||
echo "bind m setw -g mode-mouse on" >> ~/.tmux.conf
|
|
||||||
echo "bind M setw -g mode-mouse off" >> ~/.tmux.conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Set m and M to enable/disable mouse mode in tmux/byobu
|
||||||
|
echo 'bind-key m source $BYOBU_PREFIX/share/byobu/keybindings/mouse.tmux.enable \; display-message "Mouse: ON"' >> ~/.tmux.conf
|
||||||
|
echo 'bind-key M source $BYOBU_PREFIX/share/byobu/keybindings/mouse.tmux.disable \; display-message "Mouse: Off"' >> ~/.tmux.conf
|
||||||
|
|
||||||
# Install the rmate client for textmate
|
# Install the rmate client for textmate
|
||||||
install_rmate
|
inhstall_rmate && echo "Installed rmate Textmate remote "|| echo "Failed to install rmate Textmate remote"
|
||||||
|
|
||||||
# Install vim awesomerc (git amix/vimrc)
|
# Install vim awesomerc (git amix/vimrc)
|
||||||
install_vimrc
|
install_vimrc && echo "Installed vim awesome rc" || echo "Failed to install vim awesome rc"
|
||||||
# Create ssh config
|
# Create ssh config
|
||||||
create_ssh_config
|
create_ssh_config
|
||||||
|
|
||||||
# Install new zsh plugins in $ZSH/custom/plugins/
|
# Install new zsh plugins in $ZSH/custom/plugins/
|
||||||
install_zsh_plugins
|
install_zsh_plugins && echo "Installed custom zsh plugins in $ZSH/custom/plugins/" || echo "Failed to install custom zsh plugins"
|
||||||
|
|
||||||
# Comment enabled plugins in ~/.zshrc
|
# Source the plugins defined in brethil_dotfile.sh ($plugins)
|
||||||
sed -e '/plugins=\(\.*\)/ s/^#*/#/' -i $HOME/.zshrc
|
if [[ $(uname) == "Darwin" ]]; then # MacOS has a different syntax for sed
|
||||||
# Enable these plugins:
|
sed -i "" -e 's/plugins=.*/plugins=\( $plugins \)/' $HOME/.zshrc
|
||||||
plugins="plugins=(git common-aliases fast-syntax-highlighting zsh-autosuggestions colored-man-pages)"
|
else
|
||||||
echo $plugins >> $HOME/.zshrc
|
sed -i -e 's/plugins=.*/plugins=\( $plugins \)/' $HOME/.zshrc
|
||||||
|
fi
|
||||||
|
|
||||||
# Copy brethil.zsh-theme
|
# Symlink brethil.zsh-theme
|
||||||
ln -s $DOTFILES/brethil.zsh-theme $HOME/.oh-my-zsh/themes/
|
ln -s $DOTFILES/brethil.zsh-theme $HOME/.oh-my-zsh/themes/
|
||||||
|
|
||||||
# Set brethil theme
|
# Set brethil theme
|
||||||
sed -i 's/ZSH_THEME=".*"/ZSH_THEME="brethil"/' $HOME/.zshrc
|
if [[ $(uname) == "Darwin" ]]; then # MacOS has a different syntax for sed
|
||||||
|
sed -i '' 's/ZSH_THEME=".*"/ZSH_THEME="brethil"/' $HOME/.zshrc
|
||||||
|
else
|
||||||
|
sed -i 's/ZSH_THEME=".*"/ZSH_THEME="brethil"/' $HOME/.zshrc
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,9 +219,8 @@ function brethil_dotfiles_setup {
|
||||||
# Setup
|
# Setup
|
||||||
brethil_dotfiles_setup
|
brethil_dotfiles_setup
|
||||||
|
|
||||||
echo "Functions are defined in $DOTFILES/functions.sh (you can add extra functions in ~/.dotfiles_functions)"
|
echo "Functions definitions in $DOTFILES/functions.sh (you can add your own functions in ~/.dotfiles_functions)"
|
||||||
echo "Aliases are defined in $DOTFILES/aliases.sh (you can add extra aliases in ~/.dotfiles_aliases)"
|
echo "Aliases definitions in $DOTFILES/aliases.sh (you can add your own aliases in ~/.dotfiles_aliases)"
|
||||||
echo "Colors are defined in $DOTFILES/colors.sh"
|
echo "Colors are defined in $DOTFILES/colors.sh"
|
||||||
echo "These 3 files are sourced by $DOTFILES/brethil_dotfile.sh, which is in turn sourced by ~/.zshrc"
|
|
||||||
|
|
||||||
echo "Type . ~/.zshrc to source the new dotfiles, or simply launch another shell."
|
echo "Type . ~/.zshrc to source the new dotfiles, or simply launch another shell. )"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user