From 79727c84f475ad1f1877aa2fda0ededc00c1a6d5 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:41:18 -0500 Subject: [PATCH 01/19] Add mkdir and cd into directory function --- plugins/available/mkcd.plugin.bash | 1 + 1 file changed, 1 insertion(+) create mode 100644 plugins/available/mkcd.plugin.bash diff --git a/plugins/available/mkcd.plugin.bash b/plugins/available/mkcd.plugin.bash new file mode 100644 index 00000000..9fd82b25 --- /dev/null +++ b/plugins/available/mkcd.plugin.bash @@ -0,0 +1 @@ +function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; } From 2bb8e900ea2d3beb47785f5c5ab75f4bfa04bda7 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:42:17 -0500 Subject: [PATCH 02/19] Add plugin mv into tmp trash folder that gets clear on reboot (as tmp does) --- plugins/available/del.plugin.bash | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 plugins/available/del.plugin.bash diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash new file mode 100644 index 00000000..c6686cbc --- /dev/null +++ b/plugins/available/del.plugin.bash @@ -0,0 +1,2 @@ +function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } + From a88729053999e56acd704519813cfbf4f8fc9510 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:44:08 -0500 Subject: [PATCH 03/19] Tidy up blank line --- plugins/available/del.plugin.bash | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash index c6686cbc..94f08de5 100644 --- a/plugins/available/del.plugin.bash +++ b/plugins/available/del.plugin.bash @@ -1,2 +1 @@ function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } - From 8c05350c8bb15c70852d2b7844c2d5f4fc123aa5 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Sat, 29 Aug 2015 18:47:45 -0500 Subject: [PATCH 04/19] Add comments and explanations --- plugins/available/del.plugin.bash | 6 ++++++ plugins/available/mkcd.plugin.bash | 3 +++ 2 files changed, 9 insertions(+) diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash index 94f08de5..4f4237a0 100644 --- a/plugins/available/del.plugin.bash +++ b/plugins/available/del.plugin.bash @@ -1 +1,7 @@ +cite about-plugin +about-plugin 'soft delete by moving contents into a hidden folder in tmp' + +# the tmp folder gets cleared on reboot +# so this would actually remove the file on +# shutdown function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } diff --git a/plugins/available/mkcd.plugin.bash b/plugins/available/mkcd.plugin.bash index 9fd82b25..bea43f99 100644 --- a/plugins/available/mkcd.plugin.bash +++ b/plugins/available/mkcd.plugin.bash @@ -1 +1,4 @@ +cite about-plugin +about-plugin 'make and cd into a directory in one command' + function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; } From ca3f1baf80dac99e40677c46a196eaf29f2703ad Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Wed, 7 Oct 2015 15:55:38 -0500 Subject: [PATCH 05/19] Add del function to the base plugins --- plugins/available/base.plugin.bash | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index accd3610..06c52f65 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -223,3 +223,11 @@ function buf () local filetime=$(date +%Y%m%d_%H%M%S) cp -a "${filename}" "${filename}_${filetime}" } + +function del() { + about 'move files to hidden folder in tmp, that gets cleared on each reboot' + param 'file or folder to be deleted' + example 'del ./file.txt' + group 'base' + mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; +} From 9c23a1507572f56a62e73045ebce7a0db0d9a0ee Mon Sep 17 00:00:00 2001 From: Lyle Franklin Date: Wed, 7 Oct 2015 13:56:40 -0700 Subject: [PATCH 06/19] Source docker-machine environment variables rather than hardcoding Signed-off-by: Frank Kotsianas --- plugins/available/docker-machine.plugin.bash | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/available/docker-machine.plugin.bash b/plugins/available/docker-machine.plugin.bash index 8c6c146f..20bf0f29 100644 --- a/plugins/available/docker-machine.plugin.bash +++ b/plugins/available/docker-machine.plugin.bash @@ -4,8 +4,5 @@ about-plugin 'Helpers to get Docker setup correctly for docker-machine' # Note, this might need to be different if you use a machine other than 'dev', # or its configured for a different IP if [[ `uname -s` == "Darwin" ]]; then - export DOCKER_HOST="tcp://192.168.99.100:2376" - export DOCKER_CERT_PATH="$HOME/.docker/machine/machines/dev" - export DOCKER_TLS_VERIFY=1 - export DOCKER_MACHINE_NAME="dev" + eval "$(docker-machine env dev)" fi From f59ab436e4042a16d1a32986b20f018cc1365feb Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Wed, 7 Oct 2015 15:57:09 -0500 Subject: [PATCH 07/19] Delete del.plugin.bash --- plugins/available/del.plugin.bash | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 plugins/available/del.plugin.bash diff --git a/plugins/available/del.plugin.bash b/plugins/available/del.plugin.bash deleted file mode 100644 index 4f4237a0..00000000 --- a/plugins/available/del.plugin.bash +++ /dev/null @@ -1,7 +0,0 @@ -cite about-plugin -about-plugin 'soft delete by moving contents into a hidden folder in tmp' - -# the tmp folder gets cleared on reboot -# so this would actually remove the file on -# shutdown -function del() { mkdir -p /tmp/.trash && mv "$@" /tmp/.trash; } From f5d4210ffdec2f69141633a4dc9ad6a9523da524 Mon Sep 17 00:00:00 2001 From: Miguel Morales Date: Wed, 7 Oct 2015 15:57:19 -0500 Subject: [PATCH 08/19] Delete mkcd.plugin.bash --- plugins/available/mkcd.plugin.bash | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 plugins/available/mkcd.plugin.bash diff --git a/plugins/available/mkcd.plugin.bash b/plugins/available/mkcd.plugin.bash deleted file mode 100644 index bea43f99..00000000 --- a/plugins/available/mkcd.plugin.bash +++ /dev/null @@ -1,4 +0,0 @@ -cite about-plugin -about-plugin 'make and cd into a directory in one command' - -function mkcd () { mkdir -p "$@" && eval cd "\"\$$#\""; } From e704bd72f3cd9ff5b4fcae533cd71b0118eb48ed Mon Sep 17 00:00:00 2001 From: Shash Reddy Date: Thu, 8 Oct 2015 11:11:12 -0700 Subject: [PATCH 09/19] Check whether docker-machine dev is running before configuring env variables Signed-off-by: Lyle Franklin --- plugins/available/docker-machine.plugin.bash | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/available/docker-machine.plugin.bash b/plugins/available/docker-machine.plugin.bash index 20bf0f29..fc2dc44d 100644 --- a/plugins/available/docker-machine.plugin.bash +++ b/plugins/available/docker-machine.plugin.bash @@ -1,8 +1,11 @@ cite about-plugin about-plugin 'Helpers to get Docker setup correctly for docker-machine' -# Note, this might need to be different if you use a machine other than 'dev', -# or its configured for a different IP +# Note, this might need to be different if you use a machine other than 'dev' if [[ `uname -s` == "Darwin" ]]; then - eval "$(docker-machine env dev)" + # check if dev machine is running + docker-machine ls | grep --quiet 'dev.*Running' + if [[ "$?" = "0" ]]; then + eval "$(docker-machine env dev)" + fi fi From 7923b865ea997ef16a0560bc39c49dbe74c20223 Mon Sep 17 00:00:00 2001 From: Justin Dray Date: Wed, 14 Oct 2015 13:08:04 +0000 Subject: [PATCH 10/19] Allow for any install location --- install.sh | 10 ++++++---- template/bash_profile.template.bash | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/install.sh b/install.sh index 38b5d64e..77ce7270 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -BASH_IT="$HOME/.bash_it" +BASH_IT="$(dirname "$(readlink -f "$0")")" case $OSTYPE in darwin*) @@ -36,18 +36,20 @@ test -w "$HOME/$CONFIG_FILE" && cp -a "$HOME/$CONFIG_FILE" "$HOME/$CONFIG_FILE.bak" && echo -e "\033[0;32mYour original $CONFIG_FILE has been backed up to $CONFIG_FILE.bak\033[0m" -cp "$HOME/.bash_it/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" +cp "$BASH_IT/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" +sed -i "s|{{BASH_IT}}|$BASH_IT|" "$HOME/$CONFIG_FILE" +exit echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" function load_one() { file_type=$1 file_to_enable=$2 - [ ! -d "$BASH_IT/$file_type/enabled" ] && mkdir "$BASH_IT/${file_type}/enabled" + mkdir -p "$BASH_IT/${file_type}/enabled" dest="${BASH_IT}/${file_type}/enabled/${file_to_enable}" if [ ! -e "${dest}" ]; then - ln -s "../available/${file_to_enable}" "${dest}" + ln -sf "../available/${file_to_enable}" "${dest}" else echo "File ${dest} exists, skipping" fi diff --git a/template/bash_profile.template.bash b/template/bash_profile.template.bash index 9fda847e..94e04209 100755 --- a/template/bash_profile.template.bash +++ b/template/bash_profile.template.bash @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Path to the bash it configuration -export BASH_IT="$HOME/.bash_it" +export BASH_IT="{{BASH_IT}}" # Lock and Load a custom theme file # location /.bash_it/themes/ From 2d60d6ccd4ccdb7fc8b2f716da25db205b1da7e7 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Wed, 14 Oct 2015 09:59:11 -0600 Subject: [PATCH 11/19] Adding mankier.com explain() function to explain other commands --- plugins/available/explain.plugin.bash | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 plugins/available/explain.plugin.bash diff --git a/plugins/available/explain.plugin.bash b/plugins/available/explain.plugin.bash new file mode 100644 index 00000000..b2d9593a --- /dev/null +++ b/plugins/available/explain.plugin.bash @@ -0,0 +1,23 @@ +cite about-plugin +about-plugin 'mankier.com explain function to explain other commands' + +# Add this to ~/.bash_profile or ~/.bashrc +explain () { + if [ "$#" -eq 0 ]; then + while read -p "Command: " cmd; do + curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd" + done + echo "Bye!" + elif [ "$#" -eq 1 ]; then + curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$1" + else + echo "Usage" + echo "explain interactive mode." + echo "explain 'cmd -o | ...' one quoted command to explain it." + fi +} + +# Update 26-03-2015. If using this command gives no output, see if running a simple fetch causes this error: +# $ curl https://www.mankier.com +# curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s). +# If so, try specifying a cipher in the curl commands: curl --ciphers ecdhe_ecdsa_aes_128_sha From 503fc7bede567dc7244ef2388caff5767643ed8e Mon Sep 17 00:00:00 2001 From: Dwight Holman Date: Wed, 14 Oct 2015 16:58:40 -0700 Subject: [PATCH 12/19] Basename -s is platform specific, so use Bash's variable expansion instead. --- lib/preview.bash | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/preview.bash b/lib/preview.bash index 6e0d0357..306b475a 100644 --- a/lib/preview.bash +++ b/lib/preview.bash @@ -10,7 +10,8 @@ then THEMES="$BASH_IT/themes/*/*.theme.bash" for theme in $THEMES do - BASH_IT_THEME=$(basename -s '.theme.bash' $theme) + BASH_IT_THEME=${theme%.theme.bash} + BASH_IT_THEME=${BASH_IT_THEME##*/} echo " $BASH_IT_THEME" echo "" | bash --init-file $BASH_IT/bash_it.sh -i From c43f3d83273d88d2f4758c6014a0b8fcd91fa930 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 15 Oct 2015 11:26:52 +0200 Subject: [PATCH 13/19] Enabling general aliases by default --- install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/install.sh b/install.sh index 38b5d64e..0cee031c 100755 --- a/install.sh +++ b/install.sh @@ -90,6 +90,7 @@ else echo -e "\033[0;32mEnabling sane defaults\033[0m" load_one completion bash-it.completion.bash load_one plugins alias-completion.bash + load_one aliases general.aliases.bash fi echo "" From 36caf70f8d6ceaa29b3d42dd130e19b0e3660440 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Thu, 15 Oct 2015 11:27:49 +0200 Subject: [PATCH 14/19] Renamed alias-completion file to match naming conventions --- install.sh | 2 +- .../{alias-completion.bash => alias-completion.plugin.bash} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename plugins/available/{alias-completion.bash => alias-completion.plugin.bash} (100%) diff --git a/install.sh b/install.sh index 0cee031c..84dab322 100755 --- a/install.sh +++ b/install.sh @@ -89,7 +89,7 @@ else echo "" echo -e "\033[0;32mEnabling sane defaults\033[0m" load_one completion bash-it.completion.bash - load_one plugins alias-completion.bash + load_one plugins alias-completion.plugin.bash load_one aliases general.aliases.bash fi diff --git a/plugins/available/alias-completion.bash b/plugins/available/alias-completion.plugin.bash similarity index 100% rename from plugins/available/alias-completion.bash rename to plugins/available/alias-completion.plugin.bash From dad983adb5e94f0dda493dfe1ad3fcf7ef734c58 Mon Sep 17 00:00:00 2001 From: Justin Dray Date: Fri, 16 Oct 2015 16:27:58 +0200 Subject: [PATCH 15/19] Remove exit from install. Update readme for install locations --- README.md | 2 +- install.sh | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 912da87e..e8866e7f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Bash it provides a solid framework for using, developing and maintaining shell s ## Install -1. Check a clone of this repo: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` +1. Check a clone of this repo to a location of your choice, such as: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS) 3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it. 4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details). diff --git a/install.sh b/install.sh index 77ce7270..e55308c1 100755 --- a/install.sh +++ b/install.sh @@ -38,7 +38,6 @@ test -w "$HOME/$CONFIG_FILE" && cp "$BASH_IT/template/bash_profile.template.bash" "$HOME/$CONFIG_FILE" sed -i "s|{{BASH_IT}}|$BASH_IT|" "$HOME/$CONFIG_FILE" -exit echo -e "\033[0;32mCopied the template $CONFIG_FILE into ~/$CONFIG_FILE, edit this file to customize bash-it\033[0m" From 34e9878943eb8c0ffb0cee97bbdfc62d6a720e56 Mon Sep 17 00:00:00 2001 From: James Cuzella Date: Fri, 16 Oct 2015 10:11:00 -0600 Subject: [PATCH 16/19] explain: remove comments, add about, example, group, param metadata to explain() --- plugins/available/explain.plugin.bash | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/available/explain.plugin.bash b/plugins/available/explain.plugin.bash index b2d9593a..d57b78e2 100644 --- a/plugins/available/explain.plugin.bash +++ b/plugins/available/explain.plugin.bash @@ -1,8 +1,13 @@ cite about-plugin about-plugin 'mankier.com explain function to explain other commands' -# Add this to ~/.bash_profile or ~/.bashrc explain () { + about 'explain any bash command via mankier.com manpage API' + param '1: Name of the command to explain' + example '$ explain # interactive mode. Type commands to explain in REPL' + example '$ explain 'cmd -o | ...' # one quoted command to explain it.' + group 'explain' + if [ "$#" -eq 0 ]; then while read -p "Command: " cmd; do curl -Gs "https://www.mankier.com/api/explain/?cols="$(tput cols) --data-urlencode "q=$cmd" @@ -17,7 +22,3 @@ explain () { fi } -# Update 26-03-2015. If using this command gives no output, see if running a simple fetch causes this error: -# $ curl https://www.mankier.com -# curl: (35) Cannot communicate securely with peer: no common encryption algorithm(s). -# If so, try specifying a cipher in the curl commands: curl --ciphers ecdhe_ecdsa_aes_128_sha From f3542fcabed6702082c314c9c390fb7117ab8f24 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Wed, 21 Oct 2015 09:24:17 +0200 Subject: [PATCH 17/19] Added Visual Studio Code plugin Only required on Mac OS X. More details here: https://code.visualstudio.com/Docs/editor/setup --- plugins/available/visual-studio-code.plugin.bash | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 plugins/available/visual-studio-code.plugin.bash diff --git a/plugins/available/visual-studio-code.plugin.bash b/plugins/available/visual-studio-code.plugin.bash new file mode 100644 index 00000000..5bc20995 --- /dev/null +++ b/plugins/available/visual-studio-code.plugin.bash @@ -0,0 +1,12 @@ +cite about-plugin +about-plugin 'Defines the `code` executable for Visual Studio Code on OS X' + +# Based on https://code.visualstudio.com/Docs/editor/setup +if [[ `uname -s` == "Darwin" ]]; then + function code () { + about 'Starts Visual Studio Code in the provided directory' + group 'visual-studio-code' + + VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $* ; + } +fi From ad537b4c0560955d0d88f928b6c950a7f85c95a0 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Sun, 18 Oct 2015 16:14:43 +0200 Subject: [PATCH 18/19] Renamed file --- plugins/available/{boot2docker.bash => boot2docker.plugin.bash} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename plugins/available/{boot2docker.bash => boot2docker.plugin.bash} (100%) diff --git a/plugins/available/boot2docker.bash b/plugins/available/boot2docker.plugin.bash similarity index 100% rename from plugins/available/boot2docker.bash rename to plugins/available/boot2docker.plugin.bash From c23a041f82a75aa7409f45cf5c3fb27eed5069e0 Mon Sep 17 00:00:00 2001 From: Nils Winkler Date: Wed, 21 Oct 2015 09:27:40 +0200 Subject: [PATCH 19/19] Added a missing "out" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e8866e7f..49f54a33 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Bash it provides a solid framework for using, developing and maintaining shell s ## Install -1. Check a clone of this repo to a location of your choice, such as: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` +1. Check out a clone of this repo to a location of your choice, such as: `git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it` 2. Run `~/.bash_it/install.sh` (it automatically backs up your `~/.bash_profile` or `~/.bashrc`, depending on your OS) 3. Edit your modified config (`~/.bash_profile` or `~/.bashrc`) file in order to customize Bash it. 4. Check out available aliases, completions and plugins and enable the ones you want to use (see the next section for more details).