To install or not to install that is the question (Android)

To install or not to install that is the question (Android)
Photo by Denny Müller / Unsplash
$ termux-change-repo
$ termux-setup-storage
# apt update
# apt upgrade
# apt install openjdk-17
# apt install ruby
$ gem install mdless
# apt install ncurses-utils
# apt install vim
$ mkdir .shortcuts
$ vim .shortcuts/calculate_birthdays
i
#!/bin/bash

cd ~/storage/shared/Default\ Folder
java -jar CalculateBirthdays-1.0-SNAPSHOT.jar "$@"
ESC
ZZ
$ chmod +x .shortcuts/calculate_birthdays
$ vim .shortcuts/burzltag
i
#!/bin/bash
export PAGER='/data/data/com.termux/files/usr/bin/less -Xr'
cd ~/storage/shared/Default\ Folder
java -jar CalculateBirthdays-1.0-SNAPSHOT.jar print |mdless
ESC
ZZ
$ chmod +x .shortcuts/burzltag
$ vim ../usr/etc/bash.bashrc
i
######################################
#
# Termux bash.bashrc
# by brainf+ck
#
# Last modified: 2022/06/30
#
######################################

#### Global ##########################

# `grep default` highlight color
export GREP_COLOR="1;32"

# EDITOR
export EDITOR="nvim"
export SUDO_EDITOR="nvim"
export VISUAL="nvim"

# Colored man
export MANPAGER="less -R --use-color -Dd+g -Du+b"

#### History settings ################

# append to the history file, don't overwrite it
shopt -s histappend

# load results of history substitution into the readline editing buffer
shopt -s histverify

# don't put duplicate lines or lines starting with space in the history
HISTCONTROL=ignoreboth

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

#### Autocompletion ##################

# cycle through all matches with 'TAB' key
bind 'TAB:menu-complete'

# necessary for programmable completion
shopt -s extglob

# cd when entering just a path
shopt -s autocd

#### Prompt ##########################

fake_user="leder"

PS1='\[\033[0;32m\]┌──(\[\033[1;34m\]${fake_user}@\h\[\033[0;32m\])-[\[\033[0;1m\]\w\[\033[0;32m\]]
\[\033[0;32m\]└─\[\033[1;34m\]\$\[\033[0m\] '

#### Aliases #########################

# enable color support of ls, grep and ip, also add handy aliases
if [[ -x /usr/bin/dircolors ]]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    alias grep='grep --color=auto'
    alias diff='diff --color=auto'
    alias ip='ip -color'
fi

# common commands
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias lm='ls | more'
alias ll='ls -lFh'
alias la='ls -alFh --group-directories-first'
alias l1='ls -1F --group-directories-first'
alias l1m='ls -1F --group-directories-first | more'
alias lh='ls -ld .??*'
alias lsn='ls | cat -n'
alias mkdir='mkdir -p -v'
alias cp='cp --preserve=all'
alias cpv='cp --preserve=all -v'
alias cpr='cp --preserve=all -R'
alias cpp='rsync -ahW --info=progress2'
alias cs='printf "\033c"'
alias q='exit'

# memory/CPU
alias df='df -Tha --total'
alias free='free -mt'
alias ps='ps auxf'
alias ht='htop'
alias cputemp='sensors | grep Core'

# applications shortcuts
alias myip='curl -s -m 5 https://ipleak.net/json/'
alias e='nvim'
alias w3m='w3m https://duckduckgo.com'

#### Functions ######################

# If user has entered command which invokes non-available
# utility, command-not-found will give a package suggestions.
if [ -x /data/data/com.termux/files/usr/libexec/termux/command-not-found ]; then
    command_not_found_handle() {
        /data/data/com.termux/files/usr/libexec/termux/command-not-found "$1"
    }
fi

# nnn "cd on quit"
n()
{
    # Block nesting of nnn in subshells
    if [ -n $NNNVL ] && [ "${NNNVL:-0}" -ge 1 ]; then
        echo "nnn is already running"
        return
    fi

    # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
    # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to
    # see. To cd on quit only on ^G, remove the "export" and make sure not to
    # use a custom path, i.e. set NNN_TMPFILE *exactly* as follows:
    #   NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
    export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"

    # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
    # stty start undef
    # stty stop undef
    # stty lwrap undef
    # stty lnext undef

    nnn "$@"

    if [ -f "$NNN_TMPFILE" ]; then
        . "$NNN_TMPFILE"
        rm -f "$NNN_TMPFILE" > /dev/null
    fi
}

export PATH=$PATH:/data/data/com.termux/files/home/.shortcuts

export PAGER='/data/data/com.termux/files/usr/bin/less -Xr'
ESC
ZZ
$ mkdir storage/share/Default\ Folder
$ cp storage/downloads/artifacts/target/CalculateBirthdays-1.0-SNAPSHOT.jar storage/share/Default\ Folder/
  • restart termux
  • Android widget termux