mirror of
https://github.com/ohmybash/oh-my-bash.git
synced 2024-09-21 02:17:11 +00:00
Added shebash line and fix some issues
This commit is contained in:
parent
14d571a5d5
commit
ea1c9371e1
16
.gitignore
vendored
16
.gitignore
vendored
@ -1,14 +1,14 @@
|
||||
# custom files
|
||||
/custom/*
|
||||
!/custom/gitkeep
|
||||
!/custom/plugins/example
|
||||
!/custom/example.sh
|
||||
#/custom/
|
||||
#!/custom/plugins/example/
|
||||
#!/custom/example.sh
|
||||
|
||||
# temp files directories
|
||||
/cache/*
|
||||
/log/*
|
||||
!/cache/.gitkeep
|
||||
!/log/.gitkeep
|
||||
#/cache/
|
||||
#/log/
|
||||
#!/cache/.gitkeep
|
||||
#!/log/.gitkeep
|
||||
|
||||
# disabled files
|
||||
*.disabled
|
||||
.idea/
|
||||
|
2
custom/plugins/example/example.plugin.sh
Normal file
2
custom/plugins/example/example.plugin.sh
Normal file
@ -0,0 +1,2 @@
|
||||
# Add your own custom plugins in the custom/plugins directory. Plugins placed
|
||||
# here will override ones with the same name in the main plugins directory.
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
function bash_stats() {
|
||||
fc -l 1 | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Outputs current branch info in prompt format
|
||||
function git_prompt_info() {
|
||||
local ref
|
||||
|
29
lib/grep.sh
Normal file
29
lib/grep.sh
Normal file
@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
# is x grep argument available?
|
||||
grep-flag-available() {
|
||||
echo | grep $1 "" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
GREP_OPTIONS=""
|
||||
|
||||
# color grep results
|
||||
if grep-flag-available --color=auto; then
|
||||
GREP_OPTIONS+=( " --color=auto" )
|
||||
fi
|
||||
|
||||
# ignore VCS folders (if the necessary grep flags are available)
|
||||
VCS_FOLDERS="{.bzr,CVS,.git,.hg,.svn}"
|
||||
|
||||
if grep-flag-available --exclude-dir=.cvs; then
|
||||
GREP_OPTIONS+=( " --exclude-dir=$VCS_FOLDERS" )
|
||||
elif grep-flag-available --exclude=.cvs; then
|
||||
GREP_OPTIONS+=( " --exclude=$VCS_FOLDERS" )
|
||||
fi
|
||||
|
||||
# export grep settings
|
||||
alias grep="grep $GREP_OPTIONS"
|
||||
|
||||
# clean up
|
||||
unset GREP_OPTIONS
|
||||
unset VCS_FOLDERS
|
||||
unset -f grep-flag-available
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
shopt -s histappend # append to bash_history if Terminal.app quits
|
||||
|
||||
## Command history configuration
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
## jobs
|
||||
#setopt long_list_jobs
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# get the node.js version
|
||||
function nvm_prompt_info() {
|
||||
[[ -f "$NVM_DIR/nvm.sh" ]] || return
|
||||
|
37
lib/spectrum.sh
Normal file
37
lib/spectrum.sh
Normal file
@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env bash
|
||||
# A script to make using 256 colors in bash less painful.
|
||||
# P.C. Shyamshankar <sykora@lucentbeing.com>
|
||||
# Copied from http://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
|
||||
|
||||
typeset -Ag FX FG BG
|
||||
|
||||
FX=(
|
||||
reset "%{^[[00m%}"
|
||||
bold "%{^[[01m%}" no-bold "%{^[[22m%}"
|
||||
italic "%{^[[03m%}" no-italic "%{^[[23m%}"
|
||||
underline "%{^[[04m%}" no-underline "%{^[[24m%}"
|
||||
blink "%{^[[05m%}" no-blink "%{^[[25m%}"
|
||||
reverse "%{^[[07m%}" no-reverse "%{^[[27m%}"
|
||||
)
|
||||
|
||||
for color in {000..255}; do
|
||||
FG[$color]="%{^[[38;5;${color}m%}"
|
||||
BG[$color]="%{^[[48;5;${color}m%}"
|
||||
done
|
||||
|
||||
|
||||
OSH_SPECTRUM_TEXT=${OSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
|
||||
|
||||
# Show all 256 colors with color number
|
||||
function spectrum_ls() {
|
||||
for code in {000..255}; do
|
||||
print -P -- "$code: %{$FG[$code]%}$OSH_SPECTRUM_TEXT%{$reset_color%}"
|
||||
done
|
||||
}
|
||||
|
||||
# Show all 256 colors where the background is set to specific color
|
||||
function spectrum_bls() {
|
||||
for code in {000..255}; do
|
||||
print -P -- "$code: %{$BG[$code]%}$OSH_SPECTRUM_TEXT%{$reset_color%}"
|
||||
done
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Check for updates on initial load...
|
||||
if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then
|
||||
env OSH=$OSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT sh -f $OSH/tools/check_for_upgrade.sh
|
||||
env OSH=$OSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT bash -f $OSH/tools/check_for_upgrade.sh
|
||||
fi
|
||||
|
||||
# Initializes Oh My Bash
|
||||
|
@ -1,6 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright (c) 2014, NNToan - http://about.me/nntoan
|
||||
# Copyright (c) 2015, Toan Nguyen - https://nntoan.github.io
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
@ -45,59 +44,59 @@ GREEN="0;33m"
|
||||
|
||||
# main function
|
||||
function bm {
|
||||
option="${1}"
|
||||
case ${option} in
|
||||
# save current directory to bookmarks [ bm -a BOOKMARK_NAME ]
|
||||
-a)
|
||||
_save_bookmark "$2"
|
||||
;;
|
||||
# delete bookmark [ bm -d BOOKMARK_NAME ]
|
||||
-d)
|
||||
_delete_bookmark "$2"
|
||||
;;
|
||||
# jump to bookmark [ bm -g BOOKMARK_NAME ]
|
||||
-g)
|
||||
_goto_bookmark "$2"
|
||||
;;
|
||||
# print bookmark [ bm -p BOOKMARK_NAME ]
|
||||
-p)
|
||||
_print_bookmark "$2"
|
||||
;;
|
||||
# show bookmark list [ bm -l ]
|
||||
-l)
|
||||
_list_bookmark
|
||||
;;
|
||||
# help [ bm -h ]
|
||||
*)
|
||||
echo 'USAGE:'
|
||||
echo 'bm -a <bookmark_name> - Saves the current directory as "bookmark_name"'
|
||||
echo 'bm -g <bookmark_name> - Goes (cd) to the directory associated with "bookmark_name"'
|
||||
echo 'bm -p <bookmark_name> - Prints the directory associated with "bookmark_name"'
|
||||
echo 'bm -d <bookmark_name> - Deletes the bookmark'
|
||||
echo 'bm -l - Lists all available bookmarks'
|
||||
kill -SIGINT $$
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
option="${1}"
|
||||
case ${option} in
|
||||
# save current directory to bookmarks [ bm -a BOOKMARK_NAME ]
|
||||
-a)
|
||||
_save_bookmark "$2"
|
||||
;;
|
||||
# delete bookmark [ bm -d BOOKMARK_NAME ]
|
||||
-d)
|
||||
_delete_bookmark "$2"
|
||||
;;
|
||||
# jump to bookmark [ bm -g BOOKMARK_NAME ]
|
||||
-g)
|
||||
_goto_bookmark "$2"
|
||||
;;
|
||||
# print bookmark [ bm -p BOOKMARK_NAME ]
|
||||
-p)
|
||||
_print_bookmark "$2"
|
||||
;;
|
||||
# show bookmark list [ bm -l ]
|
||||
-l)
|
||||
_list_bookmark
|
||||
;;
|
||||
# help [ bm -h ]
|
||||
*)
|
||||
echo 'USAGE:'
|
||||
echo 'bm -a <bookmark_name> - Saves the current directory as "bookmark_name"'
|
||||
echo 'bm -g <bookmark_name> - Goes (cd) to the directory associated with "bookmark_name"'
|
||||
echo 'bm -p <bookmark_name> - Prints the directory associated with "bookmark_name"'
|
||||
echo 'bm -d <bookmark_name> - Deletes the bookmark'
|
||||
echo 'bm -l - Lists all available bookmarks'
|
||||
kill -SIGINT $$
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# save current directory to bookmarks
|
||||
function _save_bookmark {
|
||||
_bookmark_name_valid "$@"
|
||||
if [ -z "$exit_message" ]; then
|
||||
_purge_line "$SDIRS" "export DIR_$1="
|
||||
CURDIR=$(echo $PWD| sed "s#^$HOME#\$HOME#g")
|
||||
echo "export DIR_$1=\"$CURDIR\"" >> $SDIRS
|
||||
fi
|
||||
_bookmark_name_valid "$@"
|
||||
if [ -z "$exit_message" ]; then
|
||||
_purge_line "$SDIRS" "export DIR_$1="
|
||||
CURDIR=$(echo $PWD| sed "s#^$HOME#\$HOME#g")
|
||||
echo "export DIR_$1=\"$CURDIR\"" >> $SDIRS
|
||||
fi
|
||||
}
|
||||
|
||||
# delete bookmark
|
||||
function _delete_bookmark {
|
||||
_bookmark_name_valid "$@"
|
||||
if [ -z "$exit_message" ]; then
|
||||
_purge_line "$SDIRS" "export DIR_$1="
|
||||
unset "DIR_$1"
|
||||
fi
|
||||
_bookmark_name_valid "$@"
|
||||
if [ -z "$exit_message" ]; then
|
||||
_purge_line "$SDIRS" "export DIR_$1="
|
||||
unset "DIR_$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# jump to bookmark
|
||||
@ -157,42 +156,42 @@ function _comp {
|
||||
|
||||
# ZSH completion command
|
||||
function _compzsh {
|
||||
reply=($(_l))
|
||||
reply=($(_l))
|
||||
}
|
||||
|
||||
# safe delete line from sdirs
|
||||
function _purge_line {
|
||||
if [ -s "$1" ]; then
|
||||
# safely create a temp file
|
||||
t=$(mktemp -t bashmarks.XXXXXX) || exit 1
|
||||
trap "rm -f -- '$t'" EXIT
|
||||
if [ -s "$1" ]; then
|
||||
# safely create a temp file
|
||||
t=$(mktemp -t bashmarks.XXXXXX) || exit 1
|
||||
trap "/bin/rm -f -- '$t'" EXIT
|
||||
|
||||
# purge line
|
||||
sed "/$2/d" "$1" > "$t"
|
||||
mv "$t" "$1"
|
||||
# purge line
|
||||
sed "/$2/d" "$1" > "$t"
|
||||
/bin/mv "$t" "$1"
|
||||
|
||||
# cleanup temp file
|
||||
rm -f -- "$t"
|
||||
trap - EXIT
|
||||
fi
|
||||
# cleanup temp file
|
||||
/bin/rm -f -- "$t"
|
||||
trap - EXIT
|
||||
fi
|
||||
}
|
||||
|
||||
# bind completion command for g,p,d to _comp
|
||||
if [ $ZSH_VERSION ]; then
|
||||
compctl -K _compzsh bm -g
|
||||
compctl -K _compzsh bm -p
|
||||
compctl -K _compzsh bm -d
|
||||
compctl -K _compzsh g
|
||||
compctl -K _compzsh p
|
||||
compctl -K _compzsh d
|
||||
compctl -K _compzsh bm -g
|
||||
compctl -K _compzsh bm -p
|
||||
compctl -K _compzsh bm -d
|
||||
compctl -K _compzsh g
|
||||
compctl -K _compzsh p
|
||||
compctl -K _compzsh d
|
||||
else
|
||||
shopt -s progcomp
|
||||
complete -F _comp bm -g
|
||||
complete -F _comp bm -p
|
||||
complete -F _comp bm -d
|
||||
complete -F _comp g
|
||||
complete -F _comp p
|
||||
complete -F _comp d
|
||||
shopt -s progcomp
|
||||
complete -F _comp bm -g
|
||||
complete -F _comp bm -p
|
||||
complete -F _comp bm -d
|
||||
complete -F _comp g
|
||||
complete -F _comp p
|
||||
complete -F _comp d
|
||||
fi
|
||||
|
||||
alias s='bm -a' # Save a bookmark [bookmark_name]
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
#
|
||||
# Description: This file holds all my BASH configurations and aliases
|
||||
|
@ -1,5 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Functions
|
||||
#
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
############################---Description---###################################
|
||||
# #
|
||||
# Summary : Show a progress bar GUI on terminal platform #
|
||||
|
@ -1,68 +1,68 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Powerline theme
|
||||
__powerline() {
|
||||
|
||||
# Unicode symbols
|
||||
readonly PS_SYMBOL_DARWIN=''
|
||||
readonly PS_SYMBOL_LINUX='$'
|
||||
readonly PS_SYMBOL_OTHER='%'
|
||||
readonly GIT_BRANCH_SYMBOL='⑂ '
|
||||
readonly GIT_BRANCH_CHANGED_SYMBOL='+'
|
||||
readonly GIT_NEED_PUSH_SYMBOL='⇡'
|
||||
readonly GIT_NEED_PULL_SYMBOL='⇣'
|
||||
PS_SYMBOL_DARWIN=''
|
||||
PS_SYMBOL_LINUX='$'
|
||||
PS_SYMBOL_OTHER='%'
|
||||
GIT_BRANCH_SYMBOL='⑂ '
|
||||
GIT_BRANCH_CHANGED_SYMBOL='+'
|
||||
GIT_NEED_PUSH_SYMBOL='⇡'
|
||||
GIT_NEED_PULL_SYMBOL='⇣'
|
||||
|
||||
# Solarized colorscheme
|
||||
readonly FG_BASE03="\[$(tput setaf 8)\]"
|
||||
readonly FG_BASE02="\[$(tput setaf 0)\]"
|
||||
readonly FG_BASE01="\[$(tput setaf 10)\]"
|
||||
readonly FG_BASE00="\[$(tput setaf 11)\]"
|
||||
readonly FG_BASE0="\[$(tput setaf 12)\]"
|
||||
readonly FG_BASE1="\[$(tput setaf 14)\]"
|
||||
readonly FG_BASE2="\[$(tput setaf 7)\]"
|
||||
readonly FG_BASE3="\[$(tput setaf 15)\]"
|
||||
FG_BASE03="\[$(tput setaf 8)\]"
|
||||
FG_BASE02="\[$(tput setaf 0)\]"
|
||||
FG_BASE01="\[$(tput setaf 10)\]"
|
||||
FG_BASE00="\[$(tput setaf 11)\]"
|
||||
FG_BASE0="\[$(tput setaf 12)\]"
|
||||
FG_BASE1="\[$(tput setaf 14)\]"
|
||||
FG_BASE2="\[$(tput setaf 7)\]"
|
||||
FG_BASE3="\[$(tput setaf 15)\]"
|
||||
|
||||
readonly BG_BASE03="\[$(tput setab 8)\]"
|
||||
readonly BG_BASE02="\[$(tput setab 0)\]"
|
||||
readonly BG_BASE01="\[$(tput setab 10)\]"
|
||||
readonly BG_BASE00="\[$(tput setab 11)\]"
|
||||
readonly BG_BASE0="\[$(tput setab 12)\]"
|
||||
readonly BG_BASE1="\[$(tput setab 14)\]"
|
||||
readonly BG_BASE2="\[$(tput setab 7)\]"
|
||||
readonly BG_BASE3="\[$(tput setab 15)\]"
|
||||
BG_BASE03="\[$(tput setab 8)\]"
|
||||
BG_BASE02="\[$(tput setab 0)\]"
|
||||
BG_BASE01="\[$(tput setab 10)\]"
|
||||
BG_BASE00="\[$(tput setab 11)\]"
|
||||
BG_BASE0="\[$(tput setab 12)\]"
|
||||
BG_BASE1="\[$(tput setab 14)\]"
|
||||
BG_BASE2="\[$(tput setab 7)\]"
|
||||
BG_BASE3="\[$(tput setab 15)\]"
|
||||
|
||||
readonly FG_YELLOW="\[$(tput setaf 3)\]"
|
||||
readonly FG_ORANGE="\[$(tput setaf 9)\]"
|
||||
readonly FG_RED="\[$(tput setaf 1)\]"
|
||||
readonly FG_MAGENTA="\[$(tput setaf 5)\]"
|
||||
readonly FG_VIOLET="\[$(tput setaf 13)\]"
|
||||
readonly FG_BLUE="\[$(tput setaf 4)\]"
|
||||
readonly FG_CYAN="\[$(tput setaf 6)\]"
|
||||
readonly FG_GREEN="\[$(tput setaf 2)\]"
|
||||
FG_YELLOW="\[$(tput setaf 3)\]"
|
||||
FG_ORANGE="\[$(tput setaf 9)\]"
|
||||
FG_RED="\[$(tput setaf 1)\]"
|
||||
FG_MAGENTA="\[$(tput setaf 5)\]"
|
||||
FG_VIOLET="\[$(tput setaf 13)\]"
|
||||
FG_BLUE="\[$(tput setaf 4)\]"
|
||||
FG_CYAN="\[$(tput setaf 6)\]"
|
||||
FG_GREEN="\[$(tput setaf 2)\]"
|
||||
|
||||
readonly BG_YELLOW="\[$(tput setab 3)\]"
|
||||
readonly BG_ORANGE="\[$(tput setab 9)\]"
|
||||
readonly BG_RED="\[$(tput setab 1)\]"
|
||||
readonly BG_MAGENTA="\[$(tput setab 5)\]"
|
||||
readonly BG_VIOLET="\[$(tput setab 13)\]"
|
||||
readonly BG_BLUE="\[$(tput setab 4)\]"
|
||||
readonly BG_CYAN="\[$(tput setab 6)\]"
|
||||
readonly BG_GREEN="\[$(tput setab 2)\]"
|
||||
BG_YELLOW="\[$(tput setab 3)\]"
|
||||
BG_ORANGE="\[$(tput setab 9)\]"
|
||||
BG_RED="\[$(tput setab 1)\]"
|
||||
BG_MAGENTA="\[$(tput setab 5)\]"
|
||||
BG_VIOLET="\[$(tput setab 13)\]"
|
||||
BG_BLUE="\[$(tput setab 4)\]"
|
||||
BG_CYAN="\[$(tput setab 6)\]"
|
||||
BG_GREEN="\[$(tput setab 2)\]"
|
||||
|
||||
readonly DIM="\[$(tput dim)\]"
|
||||
readonly REVERSE="\[$(tput rev)\]"
|
||||
readonly RESET="\[$(tput sgr0)\]"
|
||||
readonly BOLD="\[$(tput bold)\]"
|
||||
DIM="\[$(tput dim)\]"
|
||||
REVERSE="\[$(tput rev)\]"
|
||||
RESET="\[$(tput sgr0)\]"
|
||||
BOLD="\[$(tput bold)\]"
|
||||
|
||||
# what OS?
|
||||
case "$(uname)" in
|
||||
Darwin)
|
||||
readonly PS_SYMBOL=$PS_SYMBOL_DARWIN
|
||||
PS_SYMBOL=$PS_SYMBOL_DARWIN
|
||||
;;
|
||||
Linux)
|
||||
readonly PS_SYMBOL=$PS_SYMBOL_LINUX
|
||||
PS_SYMBOL=$PS_SYMBOL_LINUX
|
||||
;;
|
||||
*)
|
||||
readonly PS_SYMBOL=$PS_SYMBOL_OTHER
|
||||
PS_SYMBOL=$PS_SYMBOL_OTHER
|
||||
esac
|
||||
|
||||
__git_info() {
|
||||
@ -107,4 +107,4 @@ __powerline() {
|
||||
}
|
||||
|
||||
__powerline
|
||||
unset __powerline
|
||||
unset -f __powerline
|
||||
|
@ -7,7 +7,7 @@ function _current_epoch() {
|
||||
}
|
||||
|
||||
function _update_osh_update() {
|
||||
echo "LAST_EPOCH=$(_current_epoch)" >! ~/.osh-update
|
||||
echo "LAST_EPOCH=$(_current_epoch)" >| ~/.osh-update
|
||||
}
|
||||
|
||||
function _upgrade_osh() {
|
||||
@ -42,7 +42,7 @@ if mkdir "$OSH/log/update.lock" 2>/dev/null; then
|
||||
if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then
|
||||
_upgrade_osh
|
||||
else
|
||||
echo "[Oh My Zsh] Would you like to check for updates? [Y/n]: \c"
|
||||
echo "[Oh My Bash] Would you like to check for updates? [Y/n]: \c"
|
||||
read line
|
||||
if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
|
||||
_upgrade_osh
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use colors, but only if connected to a terminal, and that terminal
|
||||
# supports them.
|
||||
if which tput >/dev/null 2>&1; then
|
||||
|
Loading…
Reference in New Issue
Block a user