diff --git a/.gitignore b/.gitignore index 3aa2bea..ded051c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ project.tmproj .rake_t_cache plugins/elocate/elocatedb +.bundle/config diff --git a/CHANGELOG b/CHANGELOG index bbd9f41..d328c91 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ +*1.0.3* (November 27, 2021) + +* Include .git directory on propagate_env_to_host +* Fix the `load_on_login` function to more accurately check if the .bashrc file is configured to load bash.env on login. + *1.0.1* (March 22, 2016) * Add Atom editor to the list of editors to automatcially search for when one is not specified. diff --git a/README.md b/README.md index 3fd4695..9b65b58 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Bash.env -**Version: 1.0.1** +**Version: 1.0.3** **Bash.env** is a cascading Bash environment system. It provides Bash shell-prompt themes, handy functions, aliases, and tools for the Bash power user. @@ -41,7 +41,7 @@ Not all development environments are the same. **Bash.env** lets you customize y After installing **Bash.env**, whenever you start a new command prompt **Bash.env** gets loaded like this: -![Overview](https://raw.github.com/midwire/.env/develop/overview.png) +![Overview](https://raw.githubusercontent.com/midwire/bash.env/master/overview.png) Lastly, your chosen theme gets loaded and you are ready for an awesome Bash session! @@ -166,6 +166,10 @@ Please send me a pull request if you create your own themes. ... which will append your public `~/.ssh/id_dsa.pub` key to the host's authorized_keys file and allow you to login without a password. + bash.env add_ssh_key_to [user@]HOSTNAME [PUBLIC_KEYFILE_PATH] + +... as above, using the specified public key. + ### Propagate your copy of Bash.env to other hosts If you want to copy your local Bash.env to another host, simply type: diff --git a/VERSION b/VERSION index 7f20734..e4c0d46 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.1 \ No newline at end of file +1.0.3 \ No newline at end of file diff --git a/bash.env.sh b/bash.env.sh index c3971c8..de925f6 100755 --- a/bash.env.sh +++ b/bash.env.sh @@ -2,7 +2,9 @@ [[ -z "$PS1" ]] && return export dot_env_path="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -export dot_env_custom="${dot_env_path}/custom" + +# Allow custom directory to exist outside of project root. +export dot_env_custom="${dot_env_custom:=${dot_env_path}/custom}" # Display .env version if [[ "$SHLVL" == "1" ]]; then diff --git a/global/alias/misc.sh b/global/alias/misc.sh index 085fd1b..b642cb3 100644 --- a/global/alias/misc.sh +++ b/global/alias/misc.sh @@ -2,5 +2,5 @@ alias c='clear' alias cls='clear' alias h='history' -alias path='echo $PATH' +alias path='echo -e ${PATH//:/\\n}' alias reloadenv=". $HOME/.env/bash.env.sh" diff --git a/global/global_functions.sh b/global/global_functions.sh index a415c00..b3dd2e6 100644 --- a/global/global_functions.sh +++ b/global/global_functions.sh @@ -29,7 +29,7 @@ function ask { function load_on_login { profile_file="$HOME/.bashrc" if [[ -f "${profile_file}" ]] && - ! grep '$HOME/.env/bash.env.sh' "$profile_file" >/dev/null 2>&1 + ! grep '. $HOME/.env/bash.env.sh' "$profile_file" >/dev/null 2>&1 then echo '[[ -r $HOME/.env/bash.env.sh ]] && . $HOME/.env/bash.env.sh' >> "$profile_file" echo ".env will now load on login." @@ -87,19 +87,31 @@ upgrade.bash.env() { # Add your public SSH key to a remote host add_ssh_key_to_host() { + local keypath if [[ $# -lt 1 ]]; then echo_warn "Usage: add_ssh_key_to_host [user@]HOSTNAME" return fi - if [[ -r "$HOME/.ssh/id_rsa.pub" ]]; then - keytype='rsa' + if [[ $# -eq 2 ]] && [[ ! -r "${2}" ]]; then + echo "Key cannot be read: ${2}" + exit 1 + elif [[ -r "${2}" ]]; then + keypath="${2}" + elif [[ -r "$HOME/.ssh/id_rsa.pub" ]]; then + keypath="$HOME/.ssh/id_rsa.pub" elif [[ -r "$HOME/.ssh/id_dsa.pub" ]]; then - keytype='dsa' + keypath="$HOME/.ssh/id_dsa.pub" else echo "You need to generate a key first: 'ssh-keygen -b 4048 -t rsa'" exit 1 fi - cat "$HOME/.ssh/id_${keytype}.pub" | ssh $1 "mkdir -p ~/.ssh; cat >> .ssh/authorized_keys" + if ! command ssh-keygen -l -f "${keypath}" 1> /dev/null + then + # use error message from command + exit 1 + fi + + cat "${keypath}" | ssh $1 "mkdir -p ~/.ssh; cat >> .ssh/authorized_keys" } # Propagate your bash.env configurations to a remote host @@ -115,7 +127,7 @@ propagate_env_to_host() { PWD=`pwd` cd $HOME echo_info "Compressing local environment..." - COPYFILE_DISABLE=1 tar cfvz $ENVFILE --exclude='.git' --exclude='.DS_Store' --exclude='.env/plugins/elocate/elocatedb' .env/ &> /dev/null + COPYFILE_DISABLE=1 tar chfvz $ENVFILE --exclude='.DS_Store' --exclude='.env/plugins/elocate/elocatedb' .env/ &> /dev/null echo_info "Copying environment to $host..." scp $ENVFILE $host: if [[ $? != 0 ]]; then echo "Copy failed!"; return; fi diff --git a/os/Darwin/functions.sh b/os/Darwin/functions.sh index c4cfb7d..bfbd4d2 100644 --- a/os/Darwin/functions.sh +++ b/os/Darwin/functions.sh @@ -45,7 +45,7 @@ findPid () { sudo /usr/sbin/lsof -t -c "$@" ; } # debug_http: download a web page and show info on what took time -debug_http () { /usr/bin/curl $@ -o /dev/null -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; } +debug_http () { /usr/bin/curl $@ -o /dev/null -s -w "dns: %{time_namelookup} connect: %{time_connect} pretransfer: %{time_pretransfer} starttransfer: %{time_starttransfer} total: %{time_total}\n" ; } # http_headers: get just the HTTP headers from a web page (and its redirects) http_headers () { /usr/bin/curl -I -L $@ ; } @@ -115,4 +115,3 @@ osacompile_rsrc () { osacompile -x -r scpt:128 -o $1 $1; } # numerical user id: 'id -u' # e.g.: ls -l /private/var/tmp/mds/$(id -u) - diff --git a/os/Linux/alias.sh b/os/Linux/alias.sh index d591db9..03d6525 100644 --- a/os/Linux/alias.sh +++ b/os/Linux/alias.sh @@ -1,3 +1,53 @@ # Editing and Sourcing aliases alias ees='. $HOME/.env/bash.env.sh' # alias bigfind="sudo find . -type f -size +30000k -exec ls -lh {} \; | awk '{ print $5 ": " $9 }'" + +#------------ +# Date/Time +#------------ +alias now='date +"%T"' +alias nowtime=now +alias nowdate='date +"%d-%m-%Y"' + +#------------ +# Networking +#------------ +alias ports='netstat -tulanp' + +## shortcut for iptables and pass it via sudo# +alias ipt='sudo /sbin/iptables' + +# display all rules # +alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers' +alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers' +alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers' +alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers' +alias firewall=iptlist + +#------------ +# Mem/CPU +#------------ +## pass options to free ## +alias meminfo='free -m -l -t' + +## get top process eating memory +alias psmem='ps auxf | sort -nr -k 4' +alias psmem10='ps auxf | sort -nr -k 4 | head -10' + +## get top process eating cpu ## +alias pscpu='ps auxf | sort -nr -k 3' +alias pscpu10='ps auxf | sort -nr -k 3 | head -10' + +## Get server cpu info ## +alias cpuinfo='lscpu' + +## older system use /proc/cpuinfo ## +##alias cpuinfo='less /proc/cpuinfo' ## + +## get GPU ram on desktop / laptop## +alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log' + +#------------ +# Disk +#------------ +alias dfree='df -HPT' diff --git a/plugins/ansible/ansible.plugin.sh b/plugins/ansible/ansible.plugin.sh new file mode 100644 index 0000000..156c13a --- /dev/null +++ b/plugins/ansible/ansible.plugin.sh @@ -0,0 +1,36 @@ +THISDIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +function treecmd { + if [[ -x $(which tree) ]]; then + tree $1 + else + find $1 + fi +} + +function ansible-role-init { + if [[ ! -z $1 ]]; then + echo "Ansible Role: $1 Creating..." + ansible-galaxy init $1 + treecmd $1 + else + echo "Usage: ansible-role-init ROLE_NAME" + fi +} + +# Ansible-related aliases +alias acfg='ansible-config' +alias acon='ansible-console' +alias adoc='ansible-doc' +alias agal='ansible-galaxy' +alias ainv='ansible-inventory' +alias ans='ansible' +alias ap='ansible-playbook' +alias aplaybook='ansible-playbook' +alias apull='ansible-pull' +alias arinit='ansible-role-init' +alias av='ansible-vault' +alias aver='ansible --version' + +# List the defined ansible aliases +alias ansible_aliases='alias|grep ansible' diff --git a/plugins/base64img/base64img.plugin.sh b/plugins/base64img/base64img.plugin.sh new file mode 100644 index 0000000..15e518e --- /dev/null +++ b/plugins/base64img/base64img.plugin.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + + +function base64img() { + if [[ "${1}" =~ ^(-h|--help) ]]; then + cat <<'EOF' +Usage: base64img + +Note: +base64 content is copied to clipboard using `pbcopy`. + +EOF + return 0 + fi + + local ext + local raw + + ext="${1##*.}" + + OS=`uname` + if [[ "$OS" == "Darwin" ]]; then + raw=$(base64 -i "${1}") + else + raw=$(base64 "${1}") + fi + printf 'data:image/%s;base64,%s' "${ext}" "${raw}" | pbcopy & + wait + printf '%s\n' "Content in clipboad." + +} + +## per bpkg guidelines +if [[ ${BASH_SOURCE[0]} != "${0}" ]]; then + export -f base64img +else + base64img "${@}" +fi diff --git a/plugins/brew/brew.plugin.sh b/plugins/brew/brew.plugin.sh new file mode 100644 index 0000000..a0add2e --- /dev/null +++ b/plugins/brew/brew.plugin.sh @@ -0,0 +1,12 @@ +# A plaguerized version of the ZSH plugin: https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/brew/brew.plugin.zsh + +# NOTE: This is for MacOs only + +alias brewp='brew pin' +alias brews='brew list -1' +alias brewsp='brew list --pinned' +alias bubo='brew update && brew outdated' +alias bubc='brew upgrade && brew cleanup' +alias bubu='bubo && bubc' +alias bcubo='brew update && brew cask outdated' +alias bcubc='brew cask reinstall $(brew cask outdated) && brew cleanup' diff --git a/plugins/bundler/bundler.plugin.sh b/plugins/bundler/bundler.plugin.sh index 544933a..c0d214a 100644 --- a/plugins/bundler/bundler.plugin.sh +++ b/plugins/bundler/bundler.plugin.sh @@ -6,6 +6,7 @@ alias bil="bi --local" alias bl="bundle list" alias bp="bundle package" alias bu="bundle update" +alias bo="bundle open" # With Rails alias bers="bundle exec rails server" diff --git a/plugins/byobu/byobu.plugin.sh b/plugins/byobu/byobu.plugin.sh new file mode 100644 index 0000000..50537b9 --- /dev/null +++ b/plugins/byobu/byobu.plugin.sh @@ -0,0 +1 @@ +export BYOBU_CHARMAP=UTF-8 diff --git a/plugins/charles-proxy/charles-proxy.plugin.sh b/plugins/charles-proxy/charles-proxy.plugin.sh new file mode 100644 index 0000000..da819f7 --- /dev/null +++ b/plugins/charles-proxy/charles-proxy.plugin.sh @@ -0,0 +1,36 @@ +# Show Current Settings +function proxy-show(){ + echo "ALL_PROXY = ($ALL_PROXY)" + echo "HTTP_PROXY = ($HTTP_PROXY)" + echo "http_proxy = ($http_proxy)" + echo "HTTPS_PROXY = ($HTTPS_PROXY)" + echo "https_proxy = ($https_proxy)" + echo "ftp_proxy = ($ftp_proxy)" + echo "rsync_proxy = ($rsync_proxy)" + echo "no_proxy = ($no_proxy)" + echo "NO_PROXY = ($NO_PROXY)" +} + +# Enable Proxy +function proxy-on(){ + export ALL_PROXY=http://localhost:8888 + export HTTP_PROXY=$ALL_PROXY + export http_proxy=$ALL_PROXY + export HTTPS_PROXY=$ALL_PROXY + export https_proxy=$ALL_PROXY + export ftp_proxy=$ALL_PROXY + export rsync_proxy=$ALL_PROXY + # export NO_PROXY=localhost,.local,169.254.,127.0.0.1,10.0.2.,.domain.com,/var/run/docker.sock + export NO_PROXY=/var/run/docker.sock + export no_proxy=$NO_PROXY + proxy-show +} + +# Disable Proxy +function proxy-off(){ + unset HTTP_PROXY HTTPS_PROXY http_proxy https_proxy ftp_proxy rsync_proxy ALL_PROXY NO_PROXY no_proxy + proxy-show +} + +# Turn on by default +proxy-on diff --git a/plugins/docker/docker.plugin.sh b/plugins/docker/docker.plugin.sh index a85417d..9158b62 100644 --- a/plugins/docker/docker.plugin.sh +++ b/plugins/docker/docker.plugin.sh @@ -1,2 +1,7 @@ # Configure the docker machine environment if which docker-machine > /dev/null; then eval $(docker-machine env default); fi + +# Remove all stopped containers +alias dck_prune="docker container prune" +# Run detached with ports exposed +alias dck_detached="docker run -d -P" diff --git a/plugins/editor/editor.plugin.sh b/plugins/editor/editor.plugin.sh index a9c2b09..102807e 100644 --- a/plugins/editor/editor.plugin.sh +++ b/plugins/editor/editor.plugin.sh @@ -10,6 +10,28 @@ if [[ -z "$EDITOR" ]]; then return 1 fi +function using_sublime() { + if [[ "$EDITOR" =~ "subl" ]]; then + # true + return 0 + else + # false + return 1 + fi +} + +function edit_project() { + if [[ using_sublime ]]; then + local project_file=$(ls -1 *.sublime-project) + if [[ -f "$project_file" ]]; then + `$EDITOR --project ./$project_file` + else + echo "Cannot find a project file for `pwd`. Editing directory instead." + `$EDITOR .` + fi + fi +} + # Common editor environment vars export CVSEDITOR="$EDITOR" export SVN_EDITOR="$EDITOR" @@ -21,6 +43,9 @@ alias edit="$EDITOR" # Load the current directory into your editor alias e="$EDITOR ." +# Edit a project +alias epr="edit_project" + # Edit/Source local host aliases. alias ea="$EDITOR $dot_env_path/host/$HOSTNAME/alias.sh" alias eas="source $dot_env_path/host/$HOSTNAME/alias.sh" diff --git a/plugins/egem/egem.sh b/plugins/egem/egem.sh index 69de4f5..7113971 100755 --- a/plugins/egem/egem.sh +++ b/plugins/egem/egem.sh @@ -13,4 +13,4 @@ usage() { GEM="$1" [ -z "$GEM" ] && usage -$EDITOR "$(gem environment gemdir)/gems/$GEM" +bundle open "$GEM" diff --git a/plugins/fzf/fzf.plugin.sh b/plugins/fzf/fzf.plugin.sh new file mode 100644 index 0000000..b902d3f --- /dev/null +++ b/plugins/fzf/fzf.plugin.sh @@ -0,0 +1,7 @@ +THISDIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +if [[ -x `which fzf` ]]; then + [ -f ~/.fzf.bash ] && source ~/.fzf.bash +else + echo "Please install 'fzf' or disable the Bash.env plugin: https://github.com/junegunn/fzf#using-homebrew-or-linuxbrew" +fi diff --git a/plugins/git/git.plugin.sh b/plugins/git/git.plugin.sh index 00d8a7e..e5f5de6 100644 --- a/plugins/git/git.plugin.sh +++ b/plugins/git/git.plugin.sh @@ -7,7 +7,6 @@ alias co='git checkout' alias commit='git commit' alias fetch='git fetch' alias gadd='git add .' -alias gt='gittower' alias merge='git merge' alias pull='git pull' alias push='git push' diff --git a/plugins/homebrew/homebrew.plugin.sh b/plugins/homebrew/homebrew.plugin.sh new file mode 100644 index 0000000..7942860 --- /dev/null +++ b/plugins/homebrew/homebrew.plugin.sh @@ -0,0 +1,3 @@ +THISDIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +export HOMEBREW_CASK_OPTS="--caskroom=/opt/homebrew-cask/Caskroom" diff --git a/plugins/jump/jump.plugin.sh b/plugins/jump/jump.plugin.sh index d7563fb..c35638e 100644 --- a/plugins/jump/jump.plugin.sh +++ b/plugins/jump/jump.plugin.sh @@ -2,12 +2,24 @@ export MARKPATH=$HOME/.marks +function marks_here { + marks | grep "`pwd`" +} + function jump { cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1" } function mark { - mkdir -p "$MARKPATH"; ln -is "$(pwd)" "$MARKPATH/$1" + mkdir -p "$MARKPATH" + if [[ -h "$MARKPATH/$1" ]]; then + echo "Remove existing mark:" + marks_here + if ask "?" Y; then + rm "$MARKPATH/$1" + fi + fi + ln -ifs "$(pwd)" "$MARKPATH/$1" } function unmark { @@ -22,7 +34,7 @@ if [[ "$OS" == "Darwin" ]]; then } else function marks { - ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo + \ls -l "$MARKPATH" | sed 's/ / /g' | cut -d' ' -f9- | sed 's/ -/\t-/g' && echo } fi diff --git a/plugins/lua/lua.plugin.sh b/plugins/lua/lua.plugin.sh new file mode 100644 index 0000000..f16e1b4 --- /dev/null +++ b/plugins/lua/lua.plugin.sh @@ -0,0 +1,5 @@ + +if [ -d "$HOME/.luarocks/bin" ]; then + pathmunge "$HOME/.luarocks/bin" +fi + diff --git a/plugins/lunarvim/lunarvim.plugin.sh b/plugins/lunarvim/lunarvim.plugin.sh new file mode 100644 index 0000000..9d71a81 --- /dev/null +++ b/plugins/lunarvim/lunarvim.plugin.sh @@ -0,0 +1 @@ +pathmunge "$HOME/.local/bin" diff --git a/plugins/nvm/README.md b/plugins/nvm/README.md new file mode 100644 index 0000000..29ddba4 --- /dev/null +++ b/plugins/nvm/README.md @@ -0,0 +1,11 @@ +# NVM Plugin + +To use just add `nvm` to your plugin array in `.bashrc`: + +``` +# Choose your plugins +plugins="nvm" +# ... other bash_env settings + +[[ -r $HOME/.env/bash.env.sh ]] && . $HOME/.env/bash.env.sh +``` diff --git a/plugins/nvm/nvm.plugin.sh b/plugins/nvm/nvm.plugin.sh new file mode 100644 index 0000000..acc6ed5 --- /dev/null +++ b/plugins/nvm/nvm.plugin.sh @@ -0,0 +1,3 @@ +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion diff --git a/plugins/psgrep/psgrep.plugin.sh b/plugins/psgrep/psgrep.plugin.sh new file mode 100644 index 0000000..109d775 --- /dev/null +++ b/plugins/psgrep/psgrep.plugin.sh @@ -0,0 +1,8 @@ +# This plugin removes the "grep" command from the output grepping through 'ps' +THISDIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# I type this way too often to not make it a plugin +# Tested on MacOs, Linux and Solaris +function psgrep { + ps aux|grep $@|grep -v grep +} diff --git a/plugins/pyenv/pyenv.plugin.sh b/plugins/pyenv/pyenv.plugin.sh new file mode 100644 index 0000000..b52d6ce --- /dev/null +++ b/plugins/pyenv/pyenv.plugin.sh @@ -0,0 +1,12 @@ +# Simple plugin to load pyenv + +if [ ! -d "$HOME/.pyenv" ]; then + echo "WARNING: You have enabled the pyenv plugin but pyenv is not installed." + echo "EXECUTE: git clone https://github.com/yyuu/pyenv.git ~/.pyenv" +else + export PYENV_ROOT="$HOME/.pyenv" + export PATH="$PYENV_ROOT/bin:$PATH" + if command -v pyenv 1>/dev/null 2>&1; then + eval "$(pyenv init -)" + fi +fi diff --git a/plugins/rbenv/_rbenv.sh b/plugins/rbenv/_rbenv.sh index c162426..025c801 100644 --- a/plugins/rbenv/_rbenv.sh +++ b/plugins/rbenv/_rbenv.sh @@ -1,3 +1,11 @@ pathmunge ~/.rbenv/bin before pathmunge ~/.rbenv/shims before if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi + +# This function is useful if you have installed ruby-build as a rbenv plugin using Git +function rbenv-update-versions { + # Update the ruby-build plugin repo + gitdir="$(rbenv root)"/plugins/ruby-build/.git + worktree="$(rbenv root)"/plugins/ruby-build + git --git-dir="$gitdir" --work-tree="$worktree" pull +} diff --git a/plugins/rust/rust.plugin.sh b/plugins/rust/rust.plugin.sh new file mode 100644 index 0000000..8851015 --- /dev/null +++ b/plugins/rust/rust.plugin.sh @@ -0,0 +1,5 @@ +# Add the path +pathmunge "$HOME/.cargo/bin" + +# Just source the environment +. "$HOME/.cargo/env" diff --git a/plugins/ssh/ssh.plugin.sh b/plugins/ssh/ssh.plugin.sh index 73ae698..2754bf1 100644 --- a/plugins/ssh/ssh.plugin.sh +++ b/plugins/ssh/ssh.plugin.sh @@ -1,2 +1,13 @@ # Add all SSH keys to the running agent -ssh-add + +KEYS=`ls -1 ~/.ssh/id_* | grep -v ".pub"` + +# Initialize ssh-agent if not running +pgrep -fx ssh-agent +if [ $? -ne 0 ]; then + eval "$(ssh-agent)" +fi + +for k in $KEYS ; do + ssh-add "$k" +done diff --git a/plugins/yarn/yarn.plugin.sh b/plugins/yarn/yarn.plugin.sh new file mode 100644 index 0000000..910aeae --- /dev/null +++ b/plugins/yarn/yarn.plugin.sh @@ -0,0 +1,2 @@ +# Just add the Yarn bin path to the path +export PATH="$(yarn global bin):$PATH" diff --git a/themes/null/local.sh b/themes/null/local.sh new file mode 100644 index 0000000..96069a9 --- /dev/null +++ b/themes/null/local.sh @@ -0,0 +1,2 @@ +# null + diff --git a/themes/null/remote.sh b/themes/null/remote.sh new file mode 100644 index 0000000..c05a79f --- /dev/null +++ b/themes/null/remote.sh @@ -0,0 +1 @@ +# null diff --git a/themes/null/theme.sh b/themes/null/theme.sh new file mode 100644 index 0000000..c05a79f --- /dev/null +++ b/themes/null/theme.sh @@ -0,0 +1 @@ +# null diff --git a/themes/transwarp_light/local.sh b/themes/transwarp_light/local.sh new file mode 100644 index 0000000..32f1554 --- /dev/null +++ b/themes/transwarp_light/local.sh @@ -0,0 +1,20 @@ +local user_host='' +local current_dir=`fgc 058`'\w'$NOC +local ruby_prompt=`fgc 124`'‹$(ps1_ruby)›'$NOC +local git_prompt=`fgc 208`'$(ps1_git_status)'`fgc 091`' $(ps1_git_branch)'$NOC +local pc='' + +# add a fix for Solaris' backward id command +id=`id |cut -f1 -d' '|sed -e 's/(.*$//'|cut -f2 -d'='` + +if [ "$id" -eq 0 ]; then + # We are root + user_host=`fgc 196`'\u'`fgc 11`'@'`fgc 27`'\H'$NOC + pc=`fgc 196`➤$NOC +else + user_host=`fgc 238`'\u'`fgc 11`'@'`fgc 27`'\H'$NOC + pc=➤$NOC +fi + +PS1="${user_host} ${current_dir} ${ruby_prompt} ${git_prompt} +${pc} "$NOC diff --git a/themes/transwarp_light/remote.sh b/themes/transwarp_light/remote.sh new file mode 100644 index 0000000..c44839b --- /dev/null +++ b/themes/transwarp_light/remote.sh @@ -0,0 +1,20 @@ +local user_host='' +local current_dir=`fgc 075`'\w'$NOC +local ruby_prompt=`fgc 009`'‹$(ps1_ruby)›'$NOC +local git_prompt=`fgc 208`'$(ps1_git_status)'`fgc 191`' $(ps1_git_branch)'$NOC +local pc='' + +# add a fix for Solaris' backward id command +id=`id |cut -f1 -d' '|sed -e 's/(.*$//'|cut -f2 -d'='` + +if [ "$id" -eq 0 ]; then + # We are root + user_host=`fgc 196`'\u'`fgc 11`'@'`bgc 9;fgc 27`'\H'$NOC + pc=`fgc 196`➤$NOC +else + user_host=`fgc 238`'\u'`fgc 11`'@'`bgc 9;fgc 255`'\H'$NOC + pc=➤$NOC +fi + +PS1="${user_host} ${current_dir} ${ruby_prompt} ${git_prompt} +${pc} "$NOC diff --git a/themes/transwarp_light/theme.sh b/themes/transwarp_light/theme.sh new file mode 100644 index 0000000..79ada56 --- /dev/null +++ b/themes/transwarp_light/theme.sh @@ -0,0 +1,17 @@ +#!/bin/bash +PROMPT_COMMAND="echo -ne \"\033]0;${USER}@${HOSTNAME}\007\"" + +function the_theme { + local thisdir=$(dirname $BASH_SOURCE) + + if [[ "$dot_env_home_host" == "$HOSTNAME" ]]; then + . "${thisdir}/local.sh" + else # We are on foreign soil + . "${thisdir}/remote.sh" + fi + +PS2='> ' +PS4='+ ' +} + +the_theme