aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:51:06 +0530
committerVikas Kushwaha <dev@vikas.rocks>2024-11-21 13:51:06 +0530
commit3d1ead045a6e53cc4625750b57d61f38f7cdad90 (patch)
tree75c7ce08962ade4f536fd35f59dc6e3d20ff4bc6 /bin
Initial commitHEADmaster
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fzf-am7
-rwxr-xr-xbin/highlight4
-rw-r--r--bin/list-all-system-activities.java14
-rwxr-xr-xbin/termux-file-editor8
-rwxr-xr-xbin/termux-install.sh90
l---------bin/termux-url-opener1
6 files changed, 124 insertions, 0 deletions
diff --git a/bin/fzf-am b/bin/fzf-am
new file mode 100755
index 0000000..1971dcd
--- /dev/null
+++ b/bin/fzf-am
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+PACKAGE="$(sudo pm list packages | fzf | cut -d: -f2)"
+
+sudo dumpsys package |
+ grep -Eo $(printf "^[[:space:]]+[0-9a-f]+[[:space:]]+%s/[^[:space:]]+" "${PACKAGE}") |
+ grep -oE "[^[:space:]]+$" | fzf
diff --git a/bin/highlight b/bin/highlight
new file mode 100755
index 0000000..34e772b
--- /dev/null
+++ b/bin/highlight
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+shift $(( $# - 1 ))
+bat --style=plain --color=always "$@"
diff --git a/bin/list-all-system-activities.java b/bin/list-all-system-activities.java
new file mode 100644
index 0000000..14f31e5
--- /dev/null
+++ b/bin/list-all-system-activities.java
@@ -0,0 +1,14 @@
+class Main {
+ public static void main(String args[]) {
+ List<PackageInfo> pInfos = getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);
+ for (PackageInfo pInfo : pInfos) {
+ ActivityInfo[] aInfos = pInfo.activities;
+ if (aInfos != null) {
+ for (ActivityInfo activityInfo : aInfos) {
+ Log.i("ACT", activityInfo.name);
+ // do whatever else you like...
+ }
+ }
+ }
+ }
+}
diff --git a/bin/termux-file-editor b/bin/termux-file-editor
new file mode 100755
index 0000000..3edb40e
--- /dev/null
+++ b/bin/termux-file-editor
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+. ~/.profile
+
+fsend "$@"
+
+printf "Press Enter to continue..."
+read -r ans
diff --git a/bin/termux-install.sh b/bin/termux-install.sh
new file mode 100755
index 0000000..8251dbb
--- /dev/null
+++ b/bin/termux-install.sh
@@ -0,0 +1,90 @@
+#!/bin/sh
+
+set -e
+cd ~ || exit
+
+err() { printf "termux-installer: %s\n" "$@" >&2; exit 1; }
+msg() { printf "$1" "$2"; }
+
+file_not_link() {
+ msg "\n:: %s: file exists but is not a symbolic link\n" "$1"
+ msg ":: Rename and continue? [Y/n] "
+ read -r ans
+ case "$ans" in y|Y|'') mv -v "$1" "$1.bak" ;; esac
+}
+
+cleardir() {
+ [ -L "$1" ] && {
+ msg "\n:: %s is a symbolic link to %s\n" "$1" "$(readlink "$1")"
+ msg ":: Skip it? [Y/n] " "$1"
+ read -r ans
+ case "$ans" in y|Y|'') return 1 ;; esac
+ }
+ [ -f "$1" ] && file_not_link "$1"
+ [ ! -d "$1" ] && return
+ msg "\n:: %s: direcotry already exists\n" "$1"
+ msg ":: Delete it? [Y/n] "
+ read -r ans
+ case "$ans" in
+ y|Y|'') rm -rf "$1" ;;
+ *) return 1 ;;
+ esac
+}
+
+echo "\n:: We need to create a link to your sdcard"
+cleardir ~/storage && {
+ msg ":: Path to your sdcard: "
+ read -r sdcard
+
+ [ -d "$sdcard" ] || err "$sdcard: No such directory"
+ echo "\n:: Contents of directory $sdcard :-"
+ ls "$sdcard/"
+ msg "\n:: Press Enter to continue..."
+ read -r ans
+ ln -sfv "$sdcard" ~/storage
+}
+
+makelink() {
+ [ -L "$2" ] && {
+ link_source="$(readlink "$2")"
+ [ "$1" = "$link_source" ] && return
+ echo "\n:: Link already exists but has an unexpected source"
+ msg ":: %s -> %s\n" "$link_source" "$2"
+ msg ":: Override? [Y/n] "
+ read -r ans
+ case "$ans" in
+ y|Y|'') ;;
+ *) return ;;
+ esac
+ }
+ [ -e "$2" ] && file_not_link "$2"
+ ln -sfv "$1" "$2"
+}
+
+makelink /sdcard ~/sdcard
+makelink /sdcard/Documents ~/Documents
+makelink /sdcard/Download/ ~/Downloads
+makelink /sdcard/Pictures/ ~/Pictures
+makelink ~/storage/Music ~/Music
+makelink ~/storage/Movies ~/Movies
+makelink ~/storage/GDrive ~/GDrive
+
+PKGS="openssh zsh tmux fzf python rsync"
+# termux-change-repo
+
+for pkg in $PKGS; do
+ dpkg-query -W "$pkg" 2>&1 >/dev/null && continue
+ msg "\n:: Installing %s...\n" "$pkg"
+ pkg install -y "$pkg"
+done
+
+cleardir ~/.termux && {
+ git clone git@github.com:csstudent41/termux-config
+ mv -v termux-config .termux
+ termux-reload-settings
+}
+
+cleardir ~/voidrice && {
+ git clone git@github.com:csstudent41/voidrice
+ rsync -Pru ~/voidrice/ ~/
+}
diff --git a/bin/termux-url-opener b/bin/termux-url-opener
new file mode 120000
index 0000000..d6607c2
--- /dev/null
+++ b/bin/termux-url-opener
@@ -0,0 +1 @@
+termux-file-editor \ No newline at end of file