first commit

This commit is contained in:
Jesús
2021-02-10 13:52:52 -05:00
commit 7e95c3b667
46 changed files with 3161 additions and 0 deletions

60
hyperterm/_custom.sh Normal file
View File

@@ -0,0 +1,60 @@
#!/bin/bash
## [Alias]
# shellcheck disable=SC1090,SC1091,SC2034,SC2154
#---------------
# Fullyclean
#---------------
alias ac='clean && clear'
#---------------
# Theme's prompt
#---------------
if [[ -f $HOME/.hyperterm/themes/joy.sh ]]; then source "$HOME/.hyperterm/themes/joy.sh"; else true; fi
if [[ -f $HOME/.hyperterm/themes/light_theme.sh ]]; then source "$HOME/.hyperterm/themes/light_theme.sh"; else true; fi
if [[ -f $HOME/.hyperterm/themes/minterm.sh ]]; then source "$HOME/.hyperterm/themes/minterm.sh"; else true; fi
if [[ -f $HOME/.hyperterm/themes/pure.sh ]]; then source "$HOME/.hyperterm/themes/pure.sh"; else true; fi
if [[ -f $HOME/.hyperterm/themes/special.sh ]]; then source "$HOME/.hyperterm/themes/special.sh"; else true; fi
#---------------
# Set Theme
#---------------
unset prompt
prompt="${default}"
#prompt="${joy}"
#prompt="${light_theme}"
#prompt="${minterm}"
#prompt="${pure}"
#prompt="${special}"
#---------------
# Tools
#---------------
if [[ -f $HOME/.hyperterm/tools/compress.sh ]]; then source "$HOME/.hyperterm/tools/compress.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/export.sh ]]; then source "$HOME/.hyperterm/tools/export.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/listuser.sh ]]; then source "$HOME/.hyperterm/tools/listuser.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/network.sh ]]; then source "$HOME/.hyperterm/tools/network.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/proxy.sh ]]; then source "$HOME/.hyperterm/tools/proxy.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/rar2zip.sh ]]; then source "$HOME/.hyperterm/tools/rar2zip.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/ruby.sh ]]; then source "$HOME/.hyperterm/tools/ruby.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/ssh-agent.sh ]]; then source "$HOME/.hyperterm/tools/ssh-agent.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/sysinfo.sh ]]; then source "$HOME/.hyperterm/tools/sysinfo.sh"; else true; fi
if [[ -f $HOME/.hyperterm/tools/virtualenv.sh ]]; then source "$HOME/.hyperterm/tools/virtualenv.sh"; else true; fi
# if [[ -f $HOME/.hyperterm/tools/vconverter.sh ]]; then source "$HOME/.hyperterm/tools/vconverter.sh"; else true; fi
#---------------
# Screenfetch
#---------------
if command -v screenfetch &> /dev/null; then screenfetch; else true; fi
#---------------
# PKGFILE
#---------------
if [[ -f /usr/share/doc/pkgfile/command-not-found.bash ]]; then source /usr/share/doc/pkgfile/command-not-found.bash; else true; fi
#---------------
# Trash-cli
#---------------
if command -v trash &> /dev/null; then alias rm='echo "This is not the command you are looking for."; false'; else true; fi
# Then, if you really want to use rm, simply prepend a slash to bypass the alias:
# \rm file-without-hope

View File

@@ -0,0 +1,22 @@
#!/bin/bash
# shellcheck disable=SC1091
# bash completion on Hyperbola: pacman -S bash-completion
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
# Autocompletado
complete -cf sudo
shopt -s cdspell
shopt -s checkwinsize
shopt -s cmdhist
shopt -s dotglob
shopt -s expand_aliases
shopt -s extglob
shopt -s histappend
shopt -s hostcomplete

96
hyperterm/core/colors.sh Normal file
View File

@@ -0,0 +1,96 @@
#!/bin/bash
function _colors_bash () {
if tput setaf 1 &> /dev/null; then
# If you would like to customize your colors, use
# # example 1
# for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; printf '%s\n' "=$c"; done
# # example 2
# for i in $(seq 0 $(tput colors)); do
# printf '%s\n' " $(tput setaf $i)Text$(tput sgr0) $(tput bold)$(tput setaf $i)Text$(tput sgr0) $(tput sgr 0 1)$(tput setaf $i)Text$(tput sgr0) \$(tput setaf $i)"
# done
# Reset the shell from our `if` check
tput sgr0 &> /dev/null
# If the terminal supports at least 256 colors, write out our 256 color based set
if [[ $(tput colors) -ge 256 ]] 2>/dev/null; then
BLUE=$(tput setaf 27)
CYAN=$(tput setaf 39)
GREEN=$(tput setaf 76)
GREY=$(tput setaf 250)
LEMON=$(tput setaf 154)
ORANGE=$(tput setaf 172)
PURPLE=$(tput setaf 200)
RED=$(tput setaf 9)
YELLOW=$(tput setaf 226)
else
# Otherwise, use colors from our set of 8
BLUE=$(tput setaf 4)
CYAN=$(tput setaf 6)
GREEN=$(tput setaf 2)
GREY=$(tput setaf 7)
LEMON=$(tput setaf 3)
ORANGE=$(tput setaf 4)
PURPLE=$(tput setaf 5)
RED=$(tput setaf 1)
YELLOW=$(tput setaf 3)
fi
BOLD=$(tput bold)
RESET=$(tput sgr0)
else
# Otherwise, use ANSI escape sequences for coloring
# If you would like to customize your colors, use
# DEV: 30-39 lines up 0-9 from `tput`
# for i in $(seq 0 109); do
# echo -n -e "\033[1;${i}mText$(tput sgr0) "
# echo "\033[1;${i}m"
# done
BLUE='\033[1;34m'
CYAN='\033[1;36m'
GREEN='\033[1;32m'
GREY='\033[0;37m'
LEMON='\033[1;33m'
ORANGE='\033[1;33m'
PURPLE='\033[1;35m'
RED='\033[1;31m'
WHITE='\033[1m'
YELLOW='\033[1;33m'
BOLD=''
RESET='\033[m'
fi
# Define the default prompt terminator character '$'
if [[ "$UID" == 0 ]]; then
SYMBOL="#"
else
SYMBOL="\$"
fi
# export
export BLUE
export CYAN
export GREEN
export GREY
export LEMON
export ORANGE
export PURPLE
export RED
export WHITE
export YELLOW
export BOLD
export RESET
export SYMBOL
}
# Xterm-colors
_xterm_fackground="xterm*background: black"
_xterm_foreground="xterm*foreground: lightgray"
if [[ ! -e "$HOME/.Xresources" && $EUID -ne 0 ]]; then
printf '%s\n%s' "$_xterm_fackground" "$_xterm_foreground" | tee -a "$HOME/.Xresources" &> /dev/null
xrdb "$HOME/.Xresources" &> /dev/null
else
xrdb "$HOME/.Xresources" &> /dev/null
fi

332
hyperterm/core/git.sh Normal file
View File

@@ -0,0 +1,332 @@
#!/bin/bash
# Set up symbols
function _symbols() {
# Import colors
_colors_bash "$@"
_synced_symbol="$(printf '%b\u2714' "${BOLD}${CYAN}")" # ✔
_dirty_synced_symbol="$(printf '%b\u002A' "${BOLD}${RED}")" #
_unpushed_symbol="$(printf '%b\u2191' "${BOLD}${CYAN}")" # ↑
_dirty_unpushed_symbol="$(printf '%b\u25B2' "${BOLD}${YELLOW}")" # ▲
_unpulled_symbol="$(printf '%b\u25BD' "${BOLD}${GREEN}")" # ▽
_dirty_unpulled_symbol="$(printf '%b\u25BC' "${BOLD}${RED}")" # ▼
_stage_symbol="$(printf '%b\u2192\u004D' "${BOLD}${CYAN}")" # →M
_unstage_symbol="$(printf '%b\u2190\u004D' "${BOLD}${RED}")" # ←M
_untracked_symbol="$(printf '%b\u003F' "${BOLD}${RED}")" # ?
_newfile_symbol="$(printf '%b\u002B' "${BOLD}${CYAN}")" # +
_deleted_file_symbol="$(printf '%b\u2013' "${BOLD}${RED}")" #
_renamed_symbol="$(printf '%b\u2387 ' "${BOLD}${RED}")" # ⎇
_unpushed_unpulled_symbol="$(printf '%b\u2B21' "${BOLD}${RED}")" # ⬡
_dirty_unpushed_unpulled_symbol="$(printf '%b\u2B22' "${BOLD}${RED}")" # ⬢
}
function _get_git_branch() {
# On branches, this will return the branch name
# On non-branches, (no branch)
ref="$(git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///')"
if [[ -n $ref ]]; then
printf '%s' "$ref"
else
printf "(no branch)"
fi
}
function _get_git_progress() {
# Detect in-progress actions (e.g. merge, rebase)
# https://github.com/git/git/blob/v1.9-rc2/wt-status.c#L1199-L1241
git_dir="$(git rev-parse --git-dir)"
# git merge
if [[ -f "$git_dir/MERGE_HEAD" ]]; then
printf " [merge]"
elif [[ -d "$git_dir/rebase-apply" ]]; then
# git am
if [[ -f "$git_dir/rebase-apply/applying" ]]; then
printf " [am]"
# git rebase
else
printf " [rebase]"
fi
elif [[ -d "$git_dir/rebase-merge" ]]; then
# git rebase --interactive/--merge
printf " [rebase]"
elif [[ -f "$git_dir/CHERRY_PICK_HEAD" ]]; then
# git cherry-pick
printf " [cherry-pick]"
fi
if [[ -f "$git_dir/BISECT_LOG" ]]; then
# git bisect
printf " [bisect]"
fi
if [[ -f "$git_dir/REVERT_HEAD" ]]; then
# git revert --no-commit
printf " [revert]"
fi
}
_prompt_is_branch1_behind_branch2 () {
# $ git log origin/master..master -1
# commit 4a633f715caf26f6e9495198f89bba20f3402a32
# Author: Todd Wolfson <todd@twolfson.com>
# Date: Sun Jul 7 22:12:17 2013 -0700
#
# Unsynced commit
# Find the first log (if any) that is in branch1 but not branch2
first_log="$(git log "$1..$2" -1 2> /dev/null)"
# Exit with 0 if there is a first log, 1 if there is not
[[ -n "$first_log" ]]
}
_prompt_branch_exists () {
# List remote branches | # Find our branch and exit with 0 or 1 if found/not found
git branch --remote 2> /dev/null | grep --quiet "$1"
}
_prompt_parse_git_ahead () {
# Grab the local and remote branch
branch="$(_get_git_branch)"
remote="$(git config --get "branch.${branch}.remote" || echo -n "origin")"
remote_branch="$remote/$branch"
# $ git log origin/master..master
# commit 4a633f715caf26f6e9495198f89bba20f3402a32
# Author: Todd Wolfson <todd@twolfson.com>
# Date: Sun Jul 7 22:12:17 2013 -0700
#
# Unsynced commit
# If the remote branch is behind the local branch
# or it has not been merged into origin (remote branch doesn't exist)
if (_prompt_is_branch1_behind_branch2 "$remote_branch" "$branch" ||
! _prompt_branch_exists "$remote_branch"); then
# printf our character
printf '%s' '0'
fi
}
_prompt_parse_git_behind() {
# Grab the branch
branch="$(_get_git_branch)"
remote="$(git config --get "branch.${branch}.remote" || echo -n "origin")"
remote_branch="$remote/$branch"
# $ git log master..origin/master
# commit 4a633f715caf26f6e9495198f89bba20f3402a32
# Author: Todd Wolfson <todd@twolfson.com>
# Date: Sun Jul 7 22:12:17 2013 -0700
#
# Unsynced commit
# If the local branch is behind the remote branch
if _prompt_is_branch1_behind_branch2 "$branch" "$remote_branch"; then
# printf our character
printf '%s' '0'
fi
}
function _prompt_parse_git_dirty() {
# If the git status has *any* changes (e.g. dirty), printf our character
if [[ -n "$(git status --porcelain 2> /dev/null)" ]]; then
printf '%s' '0'
fi
}
# start counter on git
function _git_dirty_count() {
local _dirty_status
local _git_status
_dirty_status="$(_prompt_parse_git_dirty)"
_git_status="$(git status --porcelain 2> /dev/null)"
if [[ "$_dirty_status" == 0 ]]; then
local change_count
change_count="$(echo "$_git_status" | wc -l | tr -d '[:space:]')"
if [[ "$change_count" == 1 ]]; then
printf '%b\u2022%s' "${BOLD}${GREY}" "$change_count"
elif [[ "$change_count" == 2 ]]; then
printf '%b\u2236%s' "${BOLD}${GREY}" "$change_count"
elif [[ "$change_count" == 3 ]]; then
printf '%b\u2026%s' "${BOLD}${GREY}" "$change_count"
else
printf '%b\u00BB%s' "${BOLD}${GREY}" "$change_count"
fi
else
printf ''
fi
}
# ends counter on git
function _prompt_parse_git_untracked() {
local untracked
local evaltask
untracked="$(git status 2>&1 | tee)"
grep -E 'Untracked files:' <<<"$untracked" &> /dev/null
evaltask=$?
if [ "$evaltask" -eq 0 ]; then
printf '%s' '0'
else
printf '%s' '1'
fi
}
function _prompt_parse_git_newfile() {
local newfile
local evaltask
newfile="$(git status 2>&1 | tee)"
grep -E 'new file:' <<<"$newfile" &> /dev/null
evaltask=$?
if [ "$evaltask" -eq 0 ]; then
printf '%s' '0'
else
printf '%s' '1'
fi
}
function _prompt_parse_git_deleted_file() {
local deleted_file
local evaltask
deleted_file="$(git status 2>&1 | tee)"
grep -E 'deleted:' <<<"$deleted_file" &> /dev/null
evaltask=$?
if [ "$evaltask" -eq 0 ]; then
printf '%s' '0'
else
printf '%s' '1'
fi
}
function _prompt_parse_git_renamed() {
local renamed
local evaltask
renamed="$(git status 2>&1 | tee)"
grep -E 'renamed:' <<<"$renamed" &> /dev/null
evaltask=$?
if [ "$evaltask" -eq 0 ]; then
printf '%s' '0'
else
printf '%s' '1'
fi
}
function _prompt_parse_git_unstage() {
local unstage
local evaltask
unstage="$(git status 2>&1 | tee)"
grep -E 'not staged' <<<"$unstage" &> /dev/null
evaltask=$?
if [ "$evaltask" -eq 0 ]; then
printf '%s' '0'
else
printf '%s' '1'
fi
}
function _prompt_parse_git_stage() {
local stage
local evaltask
stage="$(git status -s 2>&1 | tee)"
grep -E 'M' <<<"$stage" &> /dev/null
evaltask=$?
if [ "$evaltask" -eq 0 ]; then
printf '%s' '0'
else
printf '%s' '1'
fi
}
function _prompt_is_on_git() {
git rev-parse 2> /dev/null
}
function _prompt_get_git_status() {
_symbols "$@"
# Grab the git dirty and git behind
git_count="$(_git_dirty_count)"
dirty_branch="$(_prompt_parse_git_dirty)"
branch_ahead="$(_prompt_parse_git_ahead)"
branch_behind="$(_prompt_parse_git_behind)"
branch_stage="$(_prompt_parse_git_stage)"
branch_unstage="$(_prompt_parse_git_unstage)"
branch_untracked="$(_prompt_parse_git_untracked)"
branch_newfile="$(_prompt_parse_git_newfile)"
branch_deleted_file="$(_prompt_parse_git_deleted_file)"
branch_renamed="$(_prompt_parse_git_renamed)"
# Iterate through all the cases and if it matches, then printf
if [[ "$dirty_branch" == 0 && "$branch_ahead" == 0 && "$branch_behind" == 0 ]]; then
printf '%s%s' "$_dirty_unpushed_unpulled_symbol" "$git_count"
elif [[ "$branch_ahead" == 0 && "$branch_behind" == 0 ]]; then
printf '%s%s' "$_unpushed_unpulled_symbol" "$git_count"
elif [[ "$dirty_branch" == 0 && "$branch_ahead" == 0 ]]; then
printf '%s%s' "$_dirty_unpushed_symbol" "$git_count"
elif [[ "$branch_ahead" == 0 ]]; then
printf '%s%s' "$_unpushed_symbol" "$git_count"
elif [[ "$dirty_branch" == 0 && "$branch_behind" == 0 ]]; then
printf '%s%s' "$_dirty_unpulled_symbol" "$git_count"
elif [[ "$branch_behind" == 0 ]]; then
printf '%s%s' "$_unpulled_symbol" "$git_count"
elif [[ "$branch_unstage" == 0 && "$branch_untracked" == 0 ]]; then
printf '%s%s' "${_unstage_symbol}${_untracked_symbol}" "$git_count"
elif [[ "$branch_stage" == 0 && "$branch_untracked" == 0 ]]; then
printf '%s%s' "${_stage_symbol}${_untracked_symbol}" "$git_count"
elif [[ "$branch_stage" == 0 && "$branch_unstage" == 0 ]]; then
printf '%s%s' "$_unstage_symbol" "$git_count"
elif [[ "$branch_newfile" == 0 && "$branch_untracked" == 0 ]]; then
printf '%s%s' "${_newfile_symbol}${_untracked_symbol}" "$git_count"
elif [[ "$branch_untracked" == 0 ]]; then
printf '%s%s' "$_untracked_symbol" "$git_count"
elif [[ "$branch_stage" == 0 ]]; then
printf '%s%s' "$_stage_symbol" "$git_count"
elif [[ "$branch_newfile" == 0 ]]; then
printf '%s%s' "$_newfile_symbol" "$git_count"
elif [[ "$branch_deleted_file" == 0 ]]; then
printf '%s%s' "$_deleted_file_symbol" "$git_count"
elif [[ "$branch_renamed" == 0 ]]; then
printf '%s%s' "$_renamed_symbol" "$git_count"
elif [[ "$dirty_branch" == 0 ]]; then
printf '%s%s' "$_dirty_synced_symbol" "$git_count"
else # clean
printf '%s' "$_synced_symbol"
fi
}
_prompt_get_git_info() {
# Import colors
_colors_bash "$@"
# Grab the branch
branch="$(_get_git_branch)"
# If there are any branches
if [[ -n $branch ]]; then
# Printf the branch
output="$branch"
# Add on the git status
output="$output$(_prompt_get_git_status "$@")"
# Printf our output
printf '%b%s%b' "${BOLD}${LEMON}" "git:($output" "${BOLD}${LEMON})"
fi
}

View File

@@ -0,0 +1,30 @@
#!/bin/bash
###################
# Message functions
###################
# firts arguments is spanish
# second arguments is english
function msg() {
case ${LANG/_*/} in
es)
printf '%s\n' "$1"
;;
*)
printf '%s\n' "$2"
;;
esac
}
function msg_err() {
case ${LANG/_*/} in
es)
printf '%s\n' "$1" >&2
;;
*)
printf '%s\n' "$2" >&2
;;
esac
}

25
hyperterm/core/status.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/bin/bash
# System Status
function exitstatus(){
local retval=$?
unset status
# Import colors
_colors_bash "$@"
case $retval in
0)
status="[${retval}]"
printf '%b%s' "${BOLD}${CYAN}" "${status}"
;;
1)
status="[${retval}]"
printf '%b%s' "${BOLD}${PURPLE}" "${status}"
;;
*)
status="[${retval}]"
printf '%b%s' "${BOLD}${RED}" "${status}"
;;
esac
}

161
hyperterm/core/update.sh Normal file
View File

@@ -0,0 +1,161 @@
#!/bin/bash
# shellcheck source=/dev/null
#------------------
# Update functions
#------------------
function _which() {
command -v "$1" &> /dev/null
}
# Check URL's
# ---------------------
function _url_exists() {
if _which wget; then
if wget --spider "$1" 2>/dev/null; then
return 0 # URL 'ok'
else
return 1 # URL 'fail'
fi
elif _which curl; then
if curl --output /dev/null --silent --head --fail "$1"; then
return 0 # URL 'ok'
else
return 1 # URL 'fail'
fi
fi
}
function _urls() {
URL_1="https://git.sr.ht/~heckyel/hyperterm"
URL_2="https://notabug.org/heckyel/hyperterm"
if [[ $(_url_exists "$URL_1") -eq 0 ]]; then
URL="$URL_1"
RAW="$URL_1/blob/master"
elif [[ $(_url_exists "$URL_2") -eq 0 ]]; then
URL="$URL_2"
RAW="$URL_2/raw/master"
fi
}
# ----------------------
function ifexists_custom() {
_urls "$@"
if [ ! -e "$HOME/.hyperterm/_custom.sh" ]; then
case $1 in
wget) wget "$RAW/hyperterm/_custom.sh" -O "$HOME/.hyperterm/_custom.sh" ;;
curl) curl "$RAW/hyperterm/_custom.sh" -o "$HOME/.hyperterm/_custom.sh" ;;
git) cp -v /tmp/hyperterm/hyperterm/_custom.sh "$HOME/.hyperterm/" ;;
esac
fi
}
function updbashrc() {
_urls "$@"
# data integration
if _which wget; then
wget -nv "$RAW/hyperterm/hyperterm.sha512" -O "$HOME/.hyperterm/hyperterm.sha512" &> /dev/null
ifexists_custom wget &> /dev/null
elif _which curl; then
curl "$RAW/hyperterm/hyperterm.sha512" -o "$HOME/.hyperterm/hyperterm.sha512" &> /dev/null
ifexists_custom curl &> /dev/null
fi
# checksum of data verification
(cd "$HOME/.hyperterm/" && sha512sum -c hyperterm.sha512 &> /dev/null)
_interger=$?
if _which git; then
if [[ "$_interger" -eq 0 ]]; then
# Import colors
_colors_bash "$@"
printf '%b' "${BOLD}${CYAN}"
printf '%s\n' ' __ __ ______ '
printf '%s\n' ' / / / /_ ______ ___ ____/_ __/__ _________ ___ '
printf '%s\n' ' / /_/ / / / / __ \/ _ \/ ___// / / _ \/ ___/ __ `__ \ '
printf '%s\n' ' / __ / /_/ / /_/ / __/ / / / / __/ / / / / / / / '
printf '%s\n' ' /_/ /_/\__, / .___/\___/_/ /_/ \___/_/ /_/ /_/ /_/ '
printf '%s\n' ' /____/_/ '
printf '%s\n' ' '
printf '%b' "${BOLD}${GREY}"
msg "¡Hurra! HyperTerm se ha actualizado y/o está en la versión actual." \
"Hooray! HyperTerm has been updated and/or is at the current version."
msg "Consigue tu copia de HyperTerm en: https://notabug.org/heckyel/hyperterm" \
"Get your HyperTerm swag at: https://notabug.org/heckyel/hyperterm"
printf '%b\n' "$RESET"
else
if [[ $(_url_exists "$URL") -eq 0 ]]; then
# clone '--depth=1' not support cgit
(git clone $URL /tmp/hyperterm/ --depth=1 &> /dev/null)
printf '%s\r' "##### (33%)"
sleep 1
# core
for i in autocomplete.sh colors.sh git.sh languages.sh status.sh update.sh; do
install -m644 /tmp/hyperterm/hyperterm/core/$i "$HOME/.hyperterm/core/$i"
done
# themes
for i in default.sh joy.sh light_theme.sh pure.sh special.sh; do
install -m644 /tmp/hyperterm/hyperterm/themes/$i "$HOME/.hyperterm/themes/$i"
done
# tools
(cp -f /tmp/hyperterm/hyperterm/tools/* "$HOME/.hyperterm/tools/" &> /dev/null)
for i in hyperterm.sh hyperterm.sha512; do
install -m644 /tmp/hyperterm/hyperterm/$i "$HOME/.hyperterm/$i"
done
(cp -f /tmp/hyperterm/.bash_profile "$HOME/" &> /dev/null)
printf '%s\r' "############# (66%)"
(ifexists_custom git &> /dev/null)
sleep 1
(rm -fr /tmp/hyperterm/)
printf '%s\n' "####################### (100%) done!"
source "$HOME/.bashrc"
else
msg_err "El repo esta deshabilitado o no hay conexión a Internet" \
"The repo is disabled or connection failed"
return 1
fi
fi
else
msg_err "No hay curl y git. Por favor, instale los programas para actualizar HyperTerm" \
"I couldn't find not curl and git. Please, install the programs to update HyperTerm"
return 1
fi
}
function updbashrc_custom() {
_urls "$@"
if [[ $(_url_exists "$URL") -eq 0 ]]; then
while true
do
function _copy_c() {
if _which wget; then
wget "$RAW/hyperterm/_custom.sh" -O "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc"
elif _which curl; then
curl "$RAW/hyperterm/_custom.sh" -o "$HOME/.hyperterm/_custom.sh"; source "$HOME/.bashrc"
fi
}
question=$(msg "¿Estás seguro de sobre-escribir _custom.sh? [s/N]: " \
"Are you sure to overwrite _custom.sh? [y/N]: ")
read -r -p "$question" input
case $input in
[sS]|[yY]) _copy_c "$@"; break ;;
[nN]|"") break ;;
*) msg "Por favor responde sí o no" \
"Please answer yes or no.";;
esac
done
else
msg_err "El repo esta deshabilitado o no hay conexión a Internet" \
"The repo is disabled or connection failed"
return 1
fi
}

75
hyperterm/hyperterm.sh Normal file
View File

@@ -0,0 +1,75 @@
#!/bin/bash
#
# Custom Prompt Shell
#
# $HOME/.bashrc
#
# License: GNU GPLv3 or later
# See archive AUTHORS
#
# shellcheck disable=SC1090
xhost +local:root > /dev/null 2>&1
#---------------
# Check bash
#---------------
if [[ ! -f /bin/bash ]]; then
if [[ $(command -v bash) != /bin/bash ]]; then
printf '%s\n' "/bin/bash not found. Please run 'sudo ln -s $(command -v bash) /bin/bash'"
fi
fi
#---------------
# Emacs support
#---------------
[ "$TERM" = "dumb" ] && export PAGER=/bin/cat
#----------------
# bash_aliases
#----------------
if [[ -f $HOME/.hyperterm/tools/aliases.sh ]]; then source "$HOME/.hyperterm/tools/aliases.sh"; else true; fi
#----------------
# bash_functions
#----------------
# [ core ]
if [[ -f $HOME/.hyperterm/core/autocomplete.sh ]]; then source "$HOME/.hyperterm/core/autocomplete.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/colors.sh ]]; then source "$HOME/.hyperterm/core/colors.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/git.sh ]]; then source "$HOME/.hyperterm/core/git.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/languages.sh ]]; then source "$HOME/.hyperterm/core/languages.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/status.sh ]]; then source "$HOME/.hyperterm/core/status.sh"; else true; fi
if [[ -f $HOME/.hyperterm/core/update.sh ]]; then source "$HOME/.hyperterm/core/update.sh"; else true; fi
#-------------
# Theme
#-------------
if [[ -f $HOME/.hyperterm/themes/default.sh ]]; then source "$HOME/.hyperterm/themes/default.sh"; else true; fi
#--------------
# bashrc_custom
#--------------
if [[ -f $HOME/.hyperterm/_custom.sh ]]; then source "$HOME/.hyperterm/_custom.sh"; else true; fi
#---------------
# Shell prompt
#---------------
if [[ -d $HOME/.hyperterm && -f $HOME/.hyperterm/_custom.sh && -s $HOME/.hyperterm/_custom.sh ]]; then
PS1="${prompt:=$prompt}"
elif [[ -d $HOME/.hyperterm ]]; then
PS1="${prompt:=$default}"
else
PS1='[\u@\h \W]\$ '
fi
#Interactive Prompt
PS2="${_psi:=$_psi}"
# global unsets
unset SYMBOL prompt _psi
# clean up themes
unset default light_theme minterm pure special
# clean up colors
unset BLUE CYAN GREEN GREY LEMON ORANGE PURPLE \
RED WHITE YELLOW BOLD RESET

View File

@@ -0,0 +1,26 @@
d02b066e31cd063596fa18e47fd1d5c1f1a19b96c08285b96c1991eb95ff52e9e5096e529540222b3be30ff94726170ecf05cd9c554da137ed2baf7d248773c5 ../.bash_profile
a78784d5e732b907fc4cb4fdd817b94096f11d49acee2c26887247e924f01f363331318ea50a2235156ef43c1fec9148f49968308fe325cd90a2308b2798413c ./tools/export.sh
6f08ba1ca2f88ae12ab37bb809ce2408b39cc69c05bffb2015661b39761aaf3f50eef52f0f0779a7143c0990fd0a35696203dd7f023c2119597d57f23612f587 ./tools/virtualenv.sh
88b215a6c2df22bc84bda981b3ff1d27ba391f03e2b84b95adefe1e8885b079b0da7c885ec0ad3256b60b8da9efa9ba8ab28906ece76781b192ea474d579d143 ./tools/rar2zip.sh
81572df762582dc63ca7ce89a0aeed645931011b0d66909d9ac6c5d34d6e16ddab6a1edd385ac9328b11bb154fb6ecbe93f15c0396a0f33f6dcf4557cb430a02 ./tools/ssh-agent.sh
73becd983f15d68b3c459adb4fe847bbbd6343519640aa5e03bb530e61a59ed0545dd3b3621ad82da378bbf15c4d9ee63984004d3bfed26d9d9df643f1524de5 ./tools/proxy.sh
24ee7d176c3ee9e7080e1cc87d02f709d95bfcaad098843ff2d7de5168f8c7559a5ac79fd0da2ce81233ecbcf0b4b776aa60b6603020698482f45b080289fc4c ./tools/aliases.sh
ee1d6d1f9b010318985f7154c2a9173c8f2ab6b637cd3c8d2a9b403e83470e15a273dcff326a84f035660807d7cfcf04efe5abc0495e25ae7339b8807899cf0d ./tools/listuser.sh
a24eb94b5542e340c186acd3537d3e144b1de9e08f0cb502988959a5920133e702b598a2af714a2f81a0d475573431dd95509542e34bfb09cc5cb71bbeb1bd70 ./tools/sysinfo.sh
1d26185a78a0a779af61cdf816f0644bbd328588800ead4dcf5475b0750704fd01755edcf12048791d23cb94afae8512ef587135ff049b84c5a5c0eb0d2209a6 ./tools/compress.sh
cef212bc908eb64ddc606da86ac71f3f526369046b2292ba8884385d267cc07b2d93c8fb4f2de1dfb0d1a6f9eed028639b83da6cc854d0cd2bfb259434e09236 ./tools/vconverter.sh
579852abd8378d754fcaccb903c1fefcd4020a578ba63fb3687a08027a937fbbd18e8a1ac22b448edc14445e088134e1e909ae2f3bfea8702df8abf56000daa0 ./tools/ruby.sh
feff7e1dc5d3a84761495979eaf091dc2132fa081c3b4501756973a25e0514e9a00cc9a201767bac7d391eaee631777bbbd9bc032110e99da099c33f710a4c9f ./tools/network.sh
7447d3e167ab207d3ef4218e201a06bf5a3fc23281639f16f7f405f1d66b73923845d450fdb0a94672757866a9da0324f728564a1b61b2ed1678fe576eb565cf ./core/autocomplete.sh
065cfa39f1b4312ed275ad1039827a24f703176c653a8d27303d145f9d389a60ec5b3a9eb167e060cc6fd093b9c03cfb1a8b70254d444fbc6e62e2297d88b310 ./core/status.sh
5a362d89d5ccec7861fb33856b17e111ca95000752029529aaaa1182ca65dd84016debfec1b5a20a8f9bf43c141439fd070bc7363b82db09466dfd7cfd0b1a16 ./core/git.sh
a1c486c9cc0e623796291607d1967e98a585757ae2bd4daccd7b594d6c3ca32d14c1bde087d1edcb9a741a4748f6635ad4c381b4f8a2b86844ac7c8ef830e5e4 ./core/update.sh
f3e00b2aa8ab9f3ab44570adaa2520408ed66fd00f551654d60b64a4be3546ec781b7efa39bcd774937e654b6ffb4c7af3f21eeb36caf9c01f82f85cf28e2b4d ./core/languages.sh
1cfba599047d84a17ff92b695ebf527a505a30acc9ec21a2b9f410a7ea6dde4b23b5cf62e557d82f2fe9a8980649942424b879ca53baae4d4cb3057681baa7b6 ./core/colors.sh
ab3089453e35cc38544dffe672d532cbd559634937893a053937b599175688aecc5f3caad3064e818b883b027f27713194e3909dc3ab0246922cea00557c595a ./hyperterm.sh
8b5504c1545ff59c18af208afe6e56e5779522bfc30f96509ad88db81c183c636d2f60e9702f5d678dab610f45e31aa3ed86e379ec9b816fcc84dd6222c92014 ./themes/pure.sh
179063519b197ffac74078b3b4f8b7268b30c9b22c62dfb6885241cb06b08cfec55c017b48eefc44da96bc190840e4a435ab0468e768c37ccce0ff09f0212c00 ./themes/special.sh
050c5ca8df1c0833631f2d2783cb942c0d77417070f921fca7b2e82031d8b9bc2933e2a492dd8ff5a5dbcea6ff851670a398f942209e83fc4e7305c05aff70ad ./themes/minterm.sh
22348e57d560199b01b11ecddeb4918c7740cd2afd12780c91bed94bcabe9d8f6c9d15b4dc77ee5550944274a8e755d79734d1264dc129bba05e12de528cd174 ./themes/default.sh
fad1010c202abf2ef0bb00d74d829412c1f9459b93af870ca2f5e3e3e96105fe3f5e0c8a7aa87ad6b138439360788c4740330bd6449bfc2df28a14f8550408c9 ./themes/light_theme.sh
753feb7860eabcf22a121771028e73978b63064a9cb0e84a9a8c2727d5133b21275ee38b6517fc68aaf7aaa49382723f6b40e5bf2e2ad36e5f041c8cafa06aa0 ./themes/joy.sh

View File

@@ -0,0 +1,27 @@
#!/bin/bash
# shellcheck disable=SC1117
unset default
# Import colors
_colors_bash "$@"
default=("\n\
\[$RESET\]\
\[${BOLD}${YELLOW}\][ \u \
\[${BOLD}${BLUE}\]| \D{%Y-%m-%d} |\
\[${BOLD}${RED}\] \D{%I:%M%p} ]\n\
\[$RESET\]\
\[${BOLD}${WHITE}\][\$PWD]\[$RESET\] \
\$(exitstatus)\[$RESET\]\
\$( _prompt_is_on_git &> /dev/null && \
echo -n \" \[${BOLD}${WHITE}\]on\[$RESET\] \" && \
echo -n \"\$(_prompt_get_git_info)\" && \
echo -n \"\[${BOLD}${RED}\]\$(_get_git_progress)\" && \
echo -n \"\[$RESET\]\")\
\n\[${BOLD}${GREEN}\]$SYMBOL \[$RESET\]")
export default
unset _psi
: "${_psi:=\[${BOLD}${CYAN}\]=>\[$RESET\] }"

33
hyperterm/themes/joy.sh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
unset joy
# Import colors
_colors_bash "$@"
: "${joy:=\n\
\[${BOLD}${CYAN}\]\342\224\214\342\224\200[\
\[${BOLD}${YELLOW}\]\u\
\[${BOLD}${CYAN}\]@\
\[${BOLD}${GREY}\]\h\
\[${BOLD}${CYAN}\]]\
\342\224\200[\
\[${RESET}\]\w\
\[${BOLD}${CYAN}\]]\
\342\224\200\
\$(exitstatus)\
\[${BOLD}${CYAN}\]\
\342\224\200\
\$( _prompt_is_on_git &> /dev/null && \
echo -n \"\[$RESET\]\" && \
echo -n \"\$(_prompt_get_git_info)\" && \
echo -n \"\[${BOLD}${RED}\]\$(_get_git_progress)\" && \
echo -n \"\[$RESET\]\")\
\[${BOLD}${CYAN}\]\342\224\200[\
\[${RESET}\]\t\
\[${BOLD}${CYAN}\]]\n\
\[${BOLD}${CYAN}\]\342\224\224\342\224\200\342\224\200\342\225\274\
\[${BOLD}${GREEN}\] $SYMBOL \[$RESET\]}"
unset _psi
: "${_psi:=\[${BOLD}${CYAN}\]=>\[$RESET\] }"

View File

@@ -0,0 +1,24 @@
#!/bin/bash
unset light_theme
# Import colors
_colors_bash "$@"
: "${light_theme:=\n\
\[$RESET\]\
\[${BOLD}${CYAN}\]┌─\[$RESET\]\
\[${BOLD}${YELLOW}\]\u\[$RESET\]\
\[${BOLD}${CYAN}\]@\[$RESET\]\
\[${BOLD}${GREY}\]\h\[$RESET\] \
\$(exitstatus)\[$RESET\] \
\[${BOLD}${WHITE}\][\$PWD]\
\$( _prompt_is_on_git &> /dev/null && \
echo -n \" \[${BOLD}${WHITE}\]on\[$RESET\] \" && \
echo -n \"\$(_prompt_get_git_info)\" && \
echo -n \"\[${BOLD}${RED}\]\$(_get_git_progress)\" && \
echo -n \"\[$RESET\]\")\
\n\[${BOLD}${CYAN}\]╰─➤\[${BOLD}${GREEN}\]$SYMBOL \[$RESET\]}"
unset _psi
: "${_psi:=\[${BOLD}${CYAN}\]=>\[$RESET\] }"

View File

@@ -0,0 +1,25 @@
#!/bin/bash
unset minterm
# Import colors
_colors_bash "$@"
: "${minterm:=\n\
\[${BOLD}${CYAN}\]┌─\
\[${BOLD}${YELLOW}\]\u\
\[${BOLD}${CYAN}\]@\
\[${BOLD}${GREY}\]\h\[$RESET\] \
\$(exitstatus)\[$RESET\] \
\[${BOLD}${WHITE}\][\$PWD]\
\$( _prompt_is_on_git &> /dev/null && \
echo -n \" \[${BOLD}${WHITE}\]on\[$RESET\] \" && \
echo -n \"\$(_prompt_get_git_info)\" && \
echo -n \"\[${BOLD}${RED}\]\$(_get_git_progress)\" && \
echo -n \"\[$RESET\]\")\n\
\[${BOLD}${CYAN}\]╰─➤\[$RESET\] \
\$( echo -n \"\[${BOLD}${GREY}\]\$(date +%H:%M)\" )\[$RESET\] \
\[${BOLD}${GREEN}\]$SYMBOL \[$RESET\]}"
unset _psi
: "${_psi:=\[${BOLD}${CYAN}\]=>\[$RESET\] }"

23
hyperterm/themes/pure.sh Normal file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
unset pure
# Import colors
_colors_bash "$@"
: "${pure:=\
\[${BOLD}${GREEN}\]\u\[$RESET\] \
\[${BOLD}${YELLOW}\][\
\[${BOLD}${RED}\]\w\
\[${BOLD}${YELLOW}\]]\[$RESET\] \
\$(exitstatus)\[$RESET\] \
\[${BOLD}${BLUE}\](\$(date +%H:%M:%S))\
\$( _prompt_is_on_git &> /dev/null && \
echo -n \" \[${BOLD}${WHITE}\]on\[$RESET\] \" && \
echo -n \"\$(_prompt_get_git_info)\" && \
echo -n \"\[${BOLD}${RED}\]\$(_get_git_progress)\" && \
echo -n \"\[$RESET\]\")\
\n\[${BOLD}${CYAN}\]$SYMBOL \[$RESET\]}"
unset _psi
: "${_psi:=\[${BOLD}${CYAN}\]=>\[$RESET\] }"

View File

@@ -0,0 +1,39 @@
#!/bin/bash
# shellcheck disable=SC1117
unset special
# Import colors
_colors_bash "$@"
_prompt_local_name() {
case ${LANG/_*/} in
es)
printf "Ubicación Actual:"
;;
*)
printf "Current Location:"
;;
esac
}
special=("\n\
\[$RESET\]\
\[${BOLD}${YELLOW}\][$(_prompt_local_name)\
\[$RESET\] \[${BOLD}${GREY}\]\w\
\[${BOLD}${YELLOW}\]]\[$RESET\] \
\[${BOLD}${CYAN}\]hist:\!\[$RESET\]\n\
\[${BOLD}${GREY}\]\
\D{%Y-%m-%d}@\D{%I:%M%p}\[$RESET\] \
\$(exitstatus)\[$_PROMPT_RESET\]\
\$( _prompt_is_on_git &> /dev/null && \
echo -n \" \[${BOLD}${WHITE}\]on\[$RESET\] \" && \
echo -n \"\$(_prompt_get_git_info)\" && \
echo -n \"\[${BOLD}${RED}\]\$(_get_git_progress)\" && \
echo -n \"\[$RESET\]\")\n\
\[${BOLD}${GREEN}\]$SYMBOL \[$RESET\]")
export special
unset _psi
: "${_psi:=\[${BOLD}${CYAN}\]=>\[$RESET\] }"

View File

@@ -0,0 +1,12 @@
#!/bin/bash
alias clean='cat /dev/null > "$HOME/.bash_history" && history -c'
alias df='df -h' # human-readable sizes
alias ep='emacs PKGBUILD'
alias free='free -hm' # show sizes in humans format
alias grep='grep --color=tty -d skip'
alias la='ls -la --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias ll='ls -l --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias ls='ls --group-directories-first --time-style=+"%d.%m.%Y %H:%M" --color=auto -F'
alias np='nano PKGBUILD'
alias pastebin='curl -X POST https://bpa.st/curl -F "raw=<-"'

165
hyperterm/tools/compress.sh Normal file
View File

@@ -0,0 +1,165 @@
#!/bin/bash
# ex - archive extractor
# usage: ex <file>
function ex() {
if [ -f "$1" ] ; then
# shellcheck disable=SC2221,SC2222
case "$1" in
*.tar.bz2) tar xjf "$1" ;;
*.tar.gz) tar xzf "$1" ;;
*.tar.xz) tar xf "$1" ;;
*.tar.lz) tar xvf "$1" ;;
*.lz) lzip -d "$1" ;;
*.7z) 7z x "$1" ;;
*.bz2) bunzip2 "$1" ;;
*.gz) gunzip "$1" ;;
*.rar) unar "$1" ;;
*.tar) tar xf "$1" ;;
*.tbz2) tar xjf "$1" ;;
*.tgz) tar xzf "$1" ;;
*.xz) unxz "$1" ;;
*.Z) uncompress "$1" ;;
*.zip) unzip "$1" ;;
*) msg_err "No se puede extraer '$1' vía ex()" \
"'$1' cannot be extracted via ex()"
return 1 ;;
esac
else
msg_err "'$1' no es un archivo válido ¯\_(ツ)_/¯" \
"'$1' is not a valid file ¯\_(ツ)_/¯"
return 1
fi
}
# Compress files or directories
function cex() {
function option_compress_f() {
printf '%s\n' "1) 7z"
printf '%s\n' "2) bz2"
printf '%s\n' "3) gz"
printf '%s\n' "4) tar.bz2"
printf '%s\n' "5) tar.gz"
printf '%s\n' "6) tar.xz"
printf '%s\n' "7) tar.lz"
printf '%s\n' "8) tar"
printf '%s\n' "9) tbz2"
printf '%s\n' "10) tgz"
printf '%s\n' "11) Z"
printf '%s\n' "12) zip"
}
function option_compress_d() {
printf '%s\n' "1) 7z"
printf '%s\n' "2) tar.bz2"
printf '%s\n' "3) tar.gz"
printf '%s\n' "4) tar.xz"
printf '%s\n' "5) tar.lz"
printf '%s\n' "6) tar"
printf '%s\n' "7) tbz2"
printf '%s\n' "8) tgz"
printf '%s\n' "9) zip"
}
function log_compress() {
msg "Que tenga un buen día \o/" \
"You have a nice day \o/"
}
function invalid_option() {
msg "Archivo inválido u Opción no listada ¯\_(ツ)_/¯" \
"Invalid file or Option not listed ¯\_(ツ)_/¯"
return 1
}
function compress_f() {
read -r A
case $A in
1) 7z a "${1}.7z" "$1" ;;
2) bzip2 -k "$1" ;;
3) gzip --best --keep "$1" ;;
4) tar -c "$1" | bzip2 > "${1}.tar.bz2" ;;
5) tar -czvf "${1}.tar.gz" "$1" ;;
6) tar cJvf "${1}.tar.xz" "$1" ;;
7) tar -cvf "${1}.tar.lz" --lzip "$1" ;;
8) tar -cvf "${1}.tar" "$1" ;;
9) tar -c "$1" | bzip2 > "${1}.tbz2" ;;
10) tar -czvf "${1}.tgz" "$1" ;;
11) tar -czvf "${1}.z" "$1" ;;
12) zip -r "${1}.zip" "$1" ;;
0) log_compress "$@" ;;
*) invalid_option "$@" ;;
esac
}
function compress_d() {
read -r A
case $A in
1) 7z a "${1%/}.7z" "$1" ;;
2) tar -c "$1" | bzip2 > "${1%/}.tar.bz2" ;;
3) tar -czvf "${1%/}.tar.gz" "$1" ;;
4) tar cJvf "${1%/}.tar.xz" "$1" ;;
5) tar -cvf "${1%/}.tar.lz" --lzip "${1}" ;;
6) tar -cvf "${1%/}.tar" "$1" ;;
7) tar -c "$1" | bzip2 > "${1%/}.tbz2" ;;
8) tar -czvf "${1%/}.tgz" "$1" ;;
9) zip -r "${1%/}.zip" "$1" ;;
0) log_compress "$@" ;;
*) invalid_option "$@" ;;
esac
}
# Run
if [[ -f "$1" ]] ; then
case ${LANG/_*/} in
es)
# Print viewport user
printf '%s\n' "Elige una acción"
option_compress_f "$@"
printf '%s\n' "0) salir"
printf "Inserta la opción aquí:"
compress_f "$@"
;;
*)
# Print viewport user
printf '%s\n' "Choose option"
option_compress_f "$@"
printf '%s\n' "0) exit"
printf "Insert the option here:"
compress_f "$@"
;;
esac
elif [[ -d "$1" ]] ; then
case ${LANG/_*/} in
es)
# Print viewport user
printf '%s\n' "Elige una acción"
option_compress_d "$@"
printf '%s\n' "0) salir"
printf "Inserta la opción aquí:"
compress_d "$@"
;;
*)
# Print viewport user
printf '%s\n' "Choose option"
option_compress_d "$@"
printf '%s\n' "0) exit"
printf "Insert the option here:"
compress_d "$@"
;;
esac
else
msg_err "'$1' no es un archivo o directorio válido ¯\_(ツ)_/¯" \
"'$1' is not a valid file or directory ¯\_(ツ)_/¯"
return 1
fi
}
unset -f compress_f
unset -f compress_d
unset -f log_compress
unset -f option_compress_f
unset -f option_compress_d
unset -f invalid_option

View File

@@ -0,0 +1,6 @@
#!/bin/bash
export HISTSIZE=10000
export HISTFILESIZE=${HISTSIZE}
export HISTCONTROL=ignoreboth
export JAVA_FONTS=/usr/share/fonts/TTF

View File

@@ -0,0 +1,17 @@
#!/bin/bash
# List user
function listuser() {
case ${LANG/_*/} in
es)
printf '%s\n' "Usuario UID Shell "
printf '%s\n' "----------- ----- --------"
awk -F':' '$3>=1000 && $3<=60000 { printf "%-12s %4d %11s\n", $1, $3, $7 | "sort -r"}' /etc/passwd
;;
*)
printf '%s\n' "Users UID Shell "
printf '%s\n' "----------- ----- --------"
awk -F':' '$3>=1000 && $3<=60000 { printf "%-12s %4d %11s\n", $1, $3, $7 | "sort -r"}' /etc/passwd
;;
esac
}

View File

@@ -0,0 +1,11 @@
#!/bin/bash
# Network
function my_ip() {
unset MY_IP
: "${MY_IP:=$(ip route show table local | awk -F "local" '{print $2}' | uniq)}"
}
function my_isp() {
unset MY_ISP
: "${MY_ISP:=$(host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}')}"
}

47
hyperterm/tools/proxy.sh Normal file
View File

@@ -0,0 +1,47 @@
#!/bin/bash
function proxy_on() {
export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
if (( $# > 0 )); then
valid=$(echo "$@" | sed -n 's/\([0-9]\{1,3\}.\)\{4\}:\([0-9]\+\)/&/p')
value=$("$@")
if [[ $valid != "$value" ]]; then
>&2 echo "Invalid address"
return 1
fi
export http_proxy="http://$1/"
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
echo "Proxy environment variable set."
return 0
fi
echo -n "username: "; read -r username
if [[ $username != "" ]]; then
echo -n "password: "
read -esr password
local pre="$username:$password@"
fi
echo -n "server: "; read -r server
echo -n "port: "; read -r port
export http_proxy="http://$pre$server:$port/"
export https_proxy=$http_proxy
export ftp_proxy=$http_proxy
export rsync_proxy=$http_proxy
export HTTP_PROXY=$http_proxy
export HTTPS_PROXY=$http_proxy
export FTP_PROXY=$http_proxy
export RSYNC_PROXY=$http_proxy
}
function proxy_off(){
unset http_proxy
unset https_proxy
unset ftp_proxy
unset rsync_proxy
echo -e "Proxy environment variable removed."
}

View File

@@ -0,0 +1,58 @@
#!/bin/bash
#
# rar2zip conversion script
#
# Usage: rar2zip file [file ...]
# Example: rar2zip file.rar
function rar2zip() {
echo "Converting RARs to ZIPs"
# Use RAM disk for temporary files.
WORKDIR="/dev/shm/"
for INFILE in "$@"; do
# Absolute path to old file
OLDFILE=$(realpath "${INFILE}")
# Get the file name without the extension
BASENAME=$(basename "${OLDFILE%.*}")
# Path for the file. The ".zip" file will be written there.
DIRNAME=$(dirname "$OLDFILE")
# Name of the .zip file
NEWNAME="${DIRNAME}/$BASENAME.zip"
if [ ! -e "${NEWNAME}" ]; then
# Set name for the temp dir. This directory will be created under WORKDIR
TEMPDIR=$(mktemp -p "$WORKDIR" -d)
# Create a temporary folder for unRARed files
echo "Extracting $OLDFILE"
unar "$OLDFILE" -o "${TEMPDIR}/"
# Zip the files with maximum compression
7z a -tzip -mx=9 "$NEWNAME" "${TEMPDIR}/*"
# Alternative. MUCH SLOWER, but better compression
# 7z a -mm=Deflate -mfb=258 -mpass=15 -r "$NEWNAME" *
# Preserve file modification time
touch -r "$OLDFILE" "$NEWNAME"
# Delete the temporary directory
rm -r "$TEMPDIR"
# OPTIONAL. Safe-remove the old file
# Restore from "$HOME/.local/share/Trash"
gio trash "$OLDFILE"
echo "${OLDFILE}: A backup was made on $HOME/.local/share/Trash"
else
echo "${NEWNAME}: File exists!"
fi
done
echo "Conversion Done"
}

10
hyperterm/tools/ruby.sh Normal file
View File

@@ -0,0 +1,10 @@
#!/bin/bash
if [ -x /usr/bin/ruby ]; then
# Variable de Entorno para Sass
# Sass
_ruby="$(ruby -r rubygems -e "puts Gem.user_dir")/bin"
if [ -s "$_ruby" ]; then
export PATH+=:$_ruby
fi
fi

View File

@@ -0,0 +1,105 @@
#!/bin/bash
#------------
# SSH-AGENT
#------------
function sshagent_start {
# clean previous ssh credentials
(rm -rf /tmp/ssh-* > /dev/null)
SSH_ENV="$HOME/.ssh/environment"
printf '\e[1;36m%s\e[m\n' "Initialising new SSH agent..."
ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
chmod 600 "${SSH_ENV}"
# shellcheck source=/dev/null
source "${SSH_ENV}" > /dev/null
ssh-add -t 5d
printf '\e[1;36m%s\e[m\n' "succeeded"
}
function sshagent_stop {
# clean previous ssh credentials
(rm -rf /tmp/ssh-* > /dev/null)
ssh-agent -k > /dev/null
}
function sshagent_findsockets {
find /tmp -uid "$(id -u)" -type s -name agent.\* 2>/dev/null
}
function sshagent_testsocket {
if [ ! -x "$(command -v ssh-add)" ] ; then
echo "ssh-add is not available; agent testing aborted"
return 1
fi
if [ X"$1" != X ] ; then
export SSH_AUTH_SOCK=$1
fi
if [ X"$SSH_AUTH_SOCK" = X ] ; then
return 2
fi
if [ -S "$SSH_AUTH_SOCK" ] ; then
ssh-add -l > /dev/null
if [ $? = 2 ] ; then
echo "Socket $SSH_AUTH_SOCK is dead! Deleting!"
rm -f "$SSH_AUTH_SOCK"
return 4
else
echo "Found ssh-agent $SSH_AUTH_SOCK"
return 0
fi
else
echo "$SSH_AUTH_SOCK is not a socket!"
return 3
fi
}
function sshagent_reload {
# ssh agent sockets can be attached to a ssh daemon process or an
# ssh-agent process.
AGENTFOUND=0
# Attempt to find and use the ssh-agent in the current environment
if sshagent_testsocket ; then AGENTFOUND=1 ; fi
# If there is no agent in the environment, search /tmp for
# possible agents to reuse before starting a fresh ssh-agent
# process.
if [ $AGENTFOUND = 0 ] ; then
for agentsocket in $(sshagent_findsockets) ; do
if [ $AGENTFOUND != 0 ] ; then break ; fi
if sshagent_testsocket "$agentsocket" ; then AGENTFOUND=1 ; fi
done
fi
# If at this point we still haven't located an agent, it's time to
# start a new one
if [ $AGENTFOUND = 0 ] ; then
eval "$(ssh-agent)"
fi
# Clean up
unset AGENTFOUND
unset agentsocket
# Finally, show what keys are currently in the agent
ssh-add -l
}
if [[ -f "$HOME/.ssh/environment" ]]; then
sshagent_reload > /dev/null
fi
# Alias agents
alias sagent_start="sshagent_start"
alias sagent_stop="sshagent_stop"
# Clean up not global functions
unset -f sshagent_findsockets sshagent_testsocket

View File

@@ -0,0 +1,36 @@
#!/bin/bash
# System information
function ii() {
my_ip "$1" &> /dev/null
case ${LANG/_*/} in
es)
printf '%s\e[1;36m%s\e[m\n' "Has iniciado sesión en " "$(hostname -f)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Información adicional:" "$(uname -a)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Usuarios Conectados:" "$(who -u)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Fecha actual:" "$(date)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Estadísticas de la máquina:" "$(uptime)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Estadísticas de la memoria:" "$(free)"
printf '\n\e[1;32m%s\e[m\n' "Dirección IP Local:"
printf '%s\n' "${MY_IP:-"No conectado"}"
my_isp "$1" &> /dev/null
printf '\n\e[1;32m%s\e[m\n' "Dirección ISP:"
printf '%s\n' "${MY_ISP:-"No conectado"}"
;;
*)
printf '%s\e[1;36m%s\e[m\n' "You are logged on " "$(hostname -f)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Additionnal information:" "$(uname -a)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Users logged:" "$(who -u)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Current date:" "$(date)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Machine stats:" "$(uptime)"
printf '\n\e[1;32m%s\e[m\n%s\n' "Memory stats:" "$(free)"
printf '\n\e[1;32m%s\e[m\n' "Local IP Address:"
printf '%s\n' "${MY_IP:-"Not connected"}"
my_isp "$1" &> /dev/null
printf '\n\e[1;32m%s\e[m\n' "ISP Address:"
printf '%s\n' "${MY_ISP:-"Not connected"}"
;;
esac
}

View File

@@ -0,0 +1,72 @@
#!/bin/bash
# Converter videos to WebM-VP9
# ------------------------------
function vtovp9() {
if [[ -f "$1" && -x "$(command -v ffmpeg)" ]] ; then
case "$1" in
*.asf) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.asf}".webm ;;
*.avi) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.avi}".webm ;;
*.flv) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.flv}".webm ;;
*.mkv) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.mkv}".webm ;;
*.mov) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.mov}".webm ;;
*.mp4) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.mp4}".webm ;;
*.mpg) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.mpg}".webm ;;
*.ogv) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.ogv}".webm ;;
*.webm) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.webm}".webm ;;
*.wmv) ffmpeg -i "$1" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${1%.wmv}".webm ;;
*) msg_err "El formato de '$1' no esta listado :(" \
"The format of '$1' is not listed :("
return 1 ;;
esac
else
msg_err "Error, este no es un archivo de vídeo válido" \
"Error, this is not a valid video file"
return 1
fi
}
# Converter all videos to WebM-VP9
# --------------------------------
function alltovp9() {
if [[ -x "$(command -v rename)" ]]; then
# lowercase
for j in ASF AVI FLV MKV MOV MP4 MPG M2TS OGV VOB WMV ;
do
rename ."$j" ."${j,,}" -- *."$j" 2&> /dev/null
done
fi
sleep 1
if [[ -x "$(command -v ffmpeg)" ]]; then
for FILE_NAME in *
do
if [[ -f "$FILE_NAME" ]]; then
case "$FILE_NAME" in
*.asf) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.asf}".webm ;;
*.avi) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.avi}".webm ;;
*.flv) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.flv}".webm ;;
*.mkv) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.mkv}".webm ;;
*.mov) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.mov}".webm ;;
*.mp4) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.mp4}".webm ;;
*.mpg) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.mpg}".webm ;;
*.m2ts) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.m2ts}".webm ;;
*.ogv) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.ogv}".webm ;;
*.vob) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.vob}".webm ;;
*.wmv) ffmpeg -i "$FILE_NAME" -c:v libvpx-vp9 -crf 33 -threads 8 -b:v 0 -b:a 128k -c:a libopus -map_metadata -1 "${FILE_NAME%.wmv}".webm ;;
# Warnnig messages
*.webm) printf '\e[1;36m%s\e[m\n' "Saltando '$FILE_NAME', ya está en formato WebM" ;;
*) printf '\e[1;36m%s\e[m\n' "El formato de '$FILE_NAME' no esta listado" ;;
esac
fi
done
else
msg_err "No esta instalado ffmpeg" \
"ffmpeg is not installed"
return 1
fi
}

View File

@@ -0,0 +1,6 @@
#!/bin/bash
# shellcheck disable=SC1090
# Python virtualenv
function activate() {
source "$1/bin/activate"
}