Skip to content

Instantly share code, notes, and snippets.

@RebelLion420
Last active May 10, 2020 15:38
Show Gist options
  • Save RebelLion420/220d5ed8100e2da7e58c77f4acc3b1f3 to your computer and use it in GitHub Desktop.
Save RebelLion420/220d5ed8100e2da7e58c77f4acc3b1f3 to your computer and use it in GitHub Desktop.
Termux configs
# Personals
alias git=hub
alias vim='nvim'
alias reload='source ~/.bashrc'
alias synceach='echo "" ; for d in ./*/ ; do (cd "$d" && echo -e "* $(basename "`pwd`")" && git reset --hard HEAD && git clean -fd && git pull && echo "" || exit 1) ; done || echo -e "Error occured.\n"'
alias ls='ls -F --color=auto --group-directories-first'
alias gstart='gcloud compute instances start'
alias gstop='gcloud compute instances stop'
alias glist='gcloud compute instances list'
mkcd(){
if [ -z $1 ]; then
echo "Target Directory Required"
exit 1
fi
mkdir -p $1
cd $1
}
gitcont () {
git add .
case $1 in
"pick")
git cherry-pick --continue
;;
"merge")
git merge --continue
;;
"rebase")
git rebase --continue
;;
"revert")
git revert --continue
;;
*)
echo -e "Argument Required: pick merge rebase revert"
;;
esac
}
# .aliases by Skittles9823 2018 - 2019
# Terminal Mods
alias aflinger='rootcheck && $ROOT dumpsys media.audio_flinger'
alias bb='$BBDIR/busybox'
alias bsu='su -s bash'
alias dservice='rootcheck && $ROOT dumpsys media.dolby_memoryservice'
alias killice='rootcheck && $ROOT killall dk.icepower.icesound'
alias l='ls --group-directories-first'
alias la='l -A'
alias ll='l -l'
alias lo='l -al'
alias ls='ls --color=auto'
alias nano='nano -l'
alias killpac='rootcheck && $ROOT kill $(pidof $1)'
alias sbash='. /system/etc/bash/bashrc'
alias sudo='su -c "$@"'
alias sysro='mount -o remount,ro /system'
alias sysrw='mount -o remount,rw /system'
alias vd='cd'
# Functions which I'm gonna count as aliases
rootcheck(){ ROOT= && [ $USER = root ] || ROOT="su -c"
}
getperms(){ rootcheck && $ROOT pm get-privapp-permissions $1 | sed "s/, /\n/g"
}
getdenyperms(){ rootcheck && $ROOT pm get-privapp-deny-permissions $1 | sed "s/, /\n/g"
}
cdn(){
cmd=""
for (( i=0; i < $1; i++)) do
cmd="$cmd../"
done
cd "$cmd"
}
setpriority(){
rootcheck
case $2 in
high) $ROOT cmd overlay set-priority $1 lowest
$ROOT cmd overlay set-priority $1 highest;;
low) $ROOT cmd overlay set-priority $1 highest
$ROOT cmd overlay set-priority $1 lowest;;
*) echo "Usage: setpriority overlay [option]"
echo " "
echo "Options:"
echo " high - Sets the overlay to the highest priority"
echo " low - Sets the overlay to the lowest priority";;
esac
}
adbfi(){
rootcheck
case $1 in
on) $ROOT setprop service.adb.tcp.port 5555
$ROOT stop adbd
$ROOT start adbd
echo "ADB over WiFi enabled";;
off) $ROOT setprop service.adb.tcp.port -1
$ROOT stop adbd
$ROOT start adbd
echo "ADB over WiFi disabled";;
stats) case `getprop service.adb.tcp.port` in -1) echo "off";; 5555) echo "on";; *) echo "off";; esac;;
*) echo "Usage: adbfi [option]"
echo " "
echo "Options:"
echo " on - Enables ADB over Wifi"
echo " off - Disables ADB over WiFi"
echo " stats - Gets current status";;
esac
}
overlays(){
opt=$1
rootcheck
[ "$2" ] || opt=null
case $opt in
enable) shift
for i in $($ROOT cmd overlay list | grep -iE "^\[.*$1" | sed 's|\[.* ||g'); do $ROOT cmd overlay enable $i; done;;
disable) shift
for i in $($ROOT cmd overlay list | grep -iE "^\[.*$1" | sed 's|\[.* ||g'); do $ROOT cmd overlay disable $i; done;;
list) shift
overlayList=$($ROOT cmd overlay list | grep -iE "^\[.*$1")
echo "$overlayList";;
*) echo "Usage: overlays [option] (keyword)"
echo " "
echo "Options:"
echo " enable - Enables all overlays that include the keyword in the packagename"
echo " disable - Disables all overlays that include the keyword in the packagename"
echo " list - Lists all overlays that include the keyword in the packagename";;
esac
}
export host=android
export HOSTNAME=$(getprop ro.product.device)
export USER=$(id -un)
export BBDIR="/sbin/.magisk/busybox"
export PATH=${PATH}:/sbin:${BBDIR}:/data/data/com.termux/files/home/.local/bin:.
# Remove duplicate entries
command -v perl &>/dev/null && export PATH="$(perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, $ENV{PATH}))')" || {
echo "perl needs to be installed"
}
# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control. #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize
# Enable history appending instead of overwriting. #139609
shopt -s histappend
# Expand the history size
HISTFILESIZE=50000
HISTSIZE=10000
# ... and ignore same sucessive entries.
HISTCONTROL=ignoreboth
# establish colours for PS1
green="\\[\e[1;32m\\]"
cyan="\\[\e[1;36m\\]"
purple="\\[\e[1;35m\\]"
blank="\\[\e[m\\]"
# Sexy af PS1
PROMPT_DIRTRIM=3
export PS1="${green}┌|\@ ${cyan}$HOSTNAME $purple\w \n${green}└─${blank} \$ "
. ~/.aliases
eval $(tergent)
if [[ -n $TMUX ]]; then
~/arch/startarch l rebel
fi
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/data/data/com.termux/files/home/google-cloud-sdk/path.bash.inc' ]; then . '/data/data/com.termux/files/home/google-cloud-sdk/path.bash.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/data/data/com.termux/files/home/google-cloud-sdk/completion.bash.inc' ]; then . '/data/data/com.termux/files/home/google-cloud-sdk/completion.bash.inc'; fi
# Set default TERM
set -g default-terminal screen-256color
# Base index is 1 instead of 0
set -g base-index 1
# Enable activity monitoring for window titles
setw -g monitor-activity on
set -g visual-activity on
set -g automatic-rename on
# Constrain window size to currently connected client
setw -g aggressive-resize on
# Allows for faster key repetition
set -s escape-time 0
# Increase history for lots of scrollback
set-option -g history-limit 100000
# Enable mouse control (currently disabled due to hterm)
set -g mouse on
# Toggle mouse on
bind m \
set -g mouse on \;\
display 'Mouse: ON'
# Toggle mouse off
bind M \
set -g mouse off \;\
display 'Mouse: OFF'
# Set C-a as prefix for nested sessions
bind -n C-a send-prefix
# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# Switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Vi key bindings in copy mode
set-window-option -g mode-keys vi
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection
bind -T copy-mode-vi Enter send-keys -X page-down
bind -T copy-mode-vi Space send-keys -X page-up
# Shortcut to reload config (<Prefix> + <r>)
bind r source-file ~/.tmux.conf \; display-message "Config reloaded..."
# Plug-ins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-prefix-highlight'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-sidebar'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/vim-tmux-focus-events'
set -g @plugin 'samoshkin/tmux-plugin-sysstat'
# Plug-In Options
# Continuum
set -g @continuum-restore 'on'
# Prefix Highlight
set -g @prefix_highlight_show_copy_mode 'on'
set -g @prefix_highlight_prefix_prompt 'Wait'
set -g @prefix_highlight_copy_prompt 'Copy'
# Resurrect
set -g @resurrect-processes '"git log" ~make->make'
# Sysstat
set -g @sysstat_mem_view_tmpl'#[fg=#{mem.color3}]M:#[default]#[fg=#{mem.color},bg=#{mem.color2}]#{mem.pused}#[default]'
set -g @sysstat_mem_color_low "green default default"
set -g @sysstat_mem_color_medium "yellow default default"
set -g @sysstat_mem_color_stress "white,bold red red"
set -g @sysstat_swap_view_tmpl'#[fg=#{swap.color3}]S:#[default]#[fg=#{swap.color},bg=#{swap.color2}]#{swap.pused}#[default]'
set -g @sysstat_swap_color_low "green default default"
set -g @sysstat_swap_color_medium "yellow default default"
set -g @sysstat_swap_color_stress "white,bold red red"
#
# Status Bar Styling
set-option -g status-fg "#FFFFFF"
set-option -g status-bg default
set-window-option -g window-style fg='#FFFFFF',bg=default
set-window-option -g window-status-current-style fg=cyan,bg=default,bold
set-option -g message-style fg='#FFFFFF',bg=default,bright
set -g status-left " "
set -g status-justify left
set -g status-right "#{prefix_highlight}|#{sysstat_mem}|#{sysstat_swap}|NET:#{online_status}|"
set -g status-interval 3
# Start new connection if none exist when attaching
new -A
# Install (if missing) and initialize TMUX Plugin Manager
if "test ! -d ~/.tmux/plugins/tpm" \
"run 'git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm && ~/.tmux/plugins/tpm/tpm && ~/.tmux/plugins/tpm/bin/install_plugins'"
run -b '~/.tmux/plugins/tpm/tpm'
bsdtar
ca-certificates
curl
git
git-lfs
grep
hub
man
megatools
mosh
neovim
openssh
perl
python
python2
tergent
tmux
unzip
wget
zip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment