Skip to content

m #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open

m #1

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b5f878c
Add edit_project function for Sublime Text
Oct 31, 2016
725c1fa
Add fzf plugin - modify ssh plugin
cblackburn-ajla Feb 13, 2019
2a0bdfc
bump version to 1.0.2
cblackburn-ajla Feb 13, 2019
0a0c1f5
useful updates
cblackburn-ajla May 15, 2019
d3ae765
a null theme that does not change PS* variables
paxperscientiam May 19, 2019
cc38a78
Merge pull request #5 from paxperscientiam/themes
midwire May 20, 2019
318da4c
This plugin copies base64d images to clipboard.
paxperscientiam May 21, 2019
33b7de3
remove garbage file
paxperscientiam May 21, 2019
af07a30
Merge pull request #6 from paxperscientiam/base64img-plugin
midwire Jan 7, 2020
c81a40a
Fix the debug_http function
cblackburn-ajla Jan 7, 2020
7388a49
Add psgrep plugin
cblackburn-ajla Jan 8, 2020
8b49665
Add the Ansible plugin
cblackburn-ajla Jan 8, 2020
33d7043
Add the Homebrew plugin
cblackburn-ajla Jan 8, 2020
eeba202
Add a simple pyenv plugin
cblackburn-ajla Jan 8, 2020
4b3f222
Fix ansible-role-init
cblackburn-ajla Jan 8, 2020
700e27e
Add the NVM plugin
Jun 21, 2021
3d8b3a9
Merge branch 'add-nvm-plugin' into 'master'
Jun 21, 2021
44aa464
Add simple Yarn plugin
Jun 23, 2021
999b322
Add function to update ruby-build versions
Jun 24, 2021
969854e
Add marks_here alias to Jump plugin
Jun 24, 2021
d69cde9
Better mark removal interaction
Jun 25, 2021
dac622a
Update/Add a few plugins
Jul 7, 2021
986290c
Init ssh-agent if not running
Nov 12, 2021
74a26b4
Include .git directory on propagate_env_to_host
Nov 27, 2021
f75a5a8
Merge pull request #9 from midwire/propagate-git-directory
midwire Nov 27, 2021
84bda73
Bump patch version to 1.0.3
Nov 27, 2021
aa94fd3
Fix the overview image path
Nov 27, 2021
f3038c6
Allow user to add arbitrary public key from their system.
paxperscientiam Nov 28, 2021
925c02c
Quick example of how to specify arbitrary public key
paxperscientiam Nov 28, 2021
bf8b089
Merge pull request #11 from paxperscientiam/upload-arbitrary-publickey
midwire Nov 29, 2021
2d06485
Allow override of custom content path variable
paxperscientiam Feb 13, 2022
91969ec
Merge pull request #12 from paxperscientiam/customizeable-custom-cont…
midwire Feb 21, 2022
3971678
Remove gittower from git plugin
Aug 15, 2022
80a4bf5
Add 'bundle open' alias
Oct 27, 2022
6a59caf
Add new theme and LUA plugin
Mar 2, 2023
ac2df29
Some updates
Mar 7, 2023
b4cf270
Fix egem to use Bundler
Jan 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
project.tmproj
.rake_t_cache
plugins/elocate/elocatedb
.bundle/config
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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!

Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.1
1.0.3
4 changes: 3 additions & 1 deletion bash.env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion global/alias/misc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
24 changes: 18 additions & 6 deletions global/global_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions os/Darwin/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@ ; }
Expand Down Expand Up @@ -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)

50 changes: 50 additions & 0 deletions os/Linux/alias.sh
Original file line number Diff line number Diff line change
@@ -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'
36 changes: 36 additions & 0 deletions plugins/ansible/ansible.plugin.sh
Original file line number Diff line number Diff line change
@@ -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'
38 changes: 38 additions & 0 deletions plugins/base64img/base64img.plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env bash


function base64img() {
if [[ "${1}" =~ ^(-h|--help) ]]; then
cat <<'EOF'
Usage: base64img <PATH_TO_IMAGE_FILE>

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
12 changes: 12 additions & 0 deletions plugins/brew/brew.plugin.sh
Original file line number Diff line number Diff line change
@@ -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'
1 change: 1 addition & 0 deletions plugins/bundler/bundler.plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions plugins/byobu/byobu.plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export BYOBU_CHARMAP=UTF-8
36 changes: 36 additions & 0 deletions plugins/charles-proxy/charles-proxy.plugin.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions plugins/docker/docker.plugin.sh
Original file line number Diff line number Diff line change
@@ -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"
25 changes: 25 additions & 0 deletions plugins/editor/editor.plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion plugins/egem/egem.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ usage() {
GEM="$1"

[ -z "$GEM" ] && usage
$EDITOR "$(gem environment gemdir)/gems/$GEM"
bundle open "$GEM"
7 changes: 7 additions & 0 deletions plugins/fzf/fzf.plugin.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion plugins/git/git.plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 3 additions & 0 deletions plugins/homebrew/homebrew.plugin.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
THISDIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

export HOMEBREW_CASK_OPTS="--caskroom=/opt/homebrew-cask/Caskroom"
Loading