From cea6bbf45c11f675f6be66bdb7de9460ff8dd651 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Wed, 19 Jan 2022 23:57:35 +0300 Subject: [PATCH] feat(console): should improve running inside termux --- .bashrc | 16 ++++++++++++---- .config/sqrt-data/config.toml | 1 + .profile | 7 +++++++ Console.org | 18 +++++++++++++++++- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/.bashrc b/.bashrc index 7f53e11..9a619ca 100644 --- a/.bashrc +++ b/.bashrc @@ -11,19 +11,27 @@ fi # Startup & environment:2 ends here # [[file:Console.org::*Startup & environment][Startup & environment:3]] -if [[ -f "/etc/bashrc" ]]; then - source /etc/bashrc +if command -v termux-setup-storage > /dev/null; then + if [[ -z "$IS_ANDROID" ]]; then + source ~/.profile + fi fi # Startup & environment:3 ends here # [[file:Console.org::*Startup & environment][Startup & environment:4]] -xhost +local:root > /dev/null 2>&1 +if [[ -f "/etc/bashrc" ]]; then + source /etc/bashrc +fi # Startup & environment:4 ends here # [[file:Console.org::*Startup & environment][Startup & environment:5]] -export MANPAGER="sh -c 'sed -e s/.\\\\x08//g | bat -l man -p'" +xhost +local:root > /dev/null 2>&1 # Startup & environment:5 ends here +# [[file:Console.org::*Startup & environment][Startup & environment:6]] +export MANPAGER="sh -c 'sed -e s/.\\\\x08//g | bat -l man -p'" +# Startup & environment:6 ends here + # [[file:Console.org::*Launch fish][Launch fish:1]] use_fish=true diff --git a/.config/sqrt-data/config.toml b/.config/sqrt-data/config.toml index 76acc5e..dbac0a5 100644 --- a/.config/sqrt-data/config.toml +++ b/.config/sqrt-data/config.toml @@ -9,6 +9,7 @@ port = 5432 root = '@format {env[HOME]}/logs-sync' hash_db = '@format {this.general.root}/hash.db' temp_data_folder = '/tmp/sqrt-data' +cli_log = '@format {env[HOME]}/.local/share/sqrt-data/cli.log' [sync] log_file = '@format {this.general.root}/sync.log' diff --git a/.profile b/.profile index c54ee7c..da8b355 100644 --- a/.profile +++ b/.profile @@ -11,6 +11,13 @@ export RIPGREP_CONFIG_PATH=$HOME/.config/ripgrep/ripgreprc export LEDGER_FILE=~/Documents/org-mode/ledger/ledger.journal # Environment:3 ends here +# [[file:Console.org::*Environment][Environment:4]] +if command -v termux-setup-storage; then + export IS_ANDROID=true + [[ -f ~/.android_profile ]] && . ~/.android_profile +fi +# Environment:4 ends here + # [[file:Console.org::*My paths][My paths:1]] if [ -d "$HOME/bin" ] ; then export PATH="$HOME/bin:$PATH" diff --git a/Console.org b/Console.org index 1150673..51a7a74 100644 --- a/Console.org +++ b/Console.org @@ -66,6 +66,14 @@ hledger path #+begin_src sh export LEDGER_FILE=~/Documents/org-mode/ledger/ledger.journal #+end_src + +Checking if running inside termux +#+begin_src sh +if command -v termux-setup-storage > /dev/null; then + export IS_ANDROID=true + [[ -f ~/.android_profile ]] && . ~/.android_profile +fi +#+end_src ** My paths My script folders #+begin_src sh @@ -253,7 +261,6 @@ export SHELL #+end_src We are being invoked from a non-interactive shell. If this is an SSH session (as in "ssh host command"), source /etc/profile so we get PATH and other essential variables. - #+begin_src bash if [[ $- != *i* ]] then @@ -262,6 +269,15 @@ then fi #+end_src +If =termux-setup-storage= is available, then we're running inside termux. It is necessary to source =~/.profile= manually. +#+begin_src bash +if command -v termux-setup-storage > /dev/null; then + if [[ -z "$IS_ANDROID" ]]; then + source ~/.profile + fi +fi +#+end_src + Source the system-wide file #+begin_src bash if [[ -f "/etc/bashrc" ]]; then