Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize adb prompt

Tags:

android

adb

How can I reduce the length of the path printed before the prompt of the shell opened by adb shell? My problem is that it is so long that I can no longer see my commands because the doesn't break the line automatically. I would prefer something like the name of the current directory or an abstract code example.

sh -v on Android phone gives me

# Copyright (c) 2010
#   Thorsten Glaser <[email protected]>
# This file is provided under the same terms as mksh.
#-
# Minimal /system/etc/mkshrc for Android

: ${TERM:=vt100} ${HOME:=/data} ${MKSH:=/system/bin/sh} ${HOSTNAME:=android}
: ${SHELL:=$MKSH} ${USER:=$(typeset x=$(id); x=${x#*\(}; print -r -- ${x%%\)*})}
if (( USER_ID )); then PS1='$'; else PS1='#'; fi
function precmd {
    typeset e=$?

    (( e )) && print -n "$e|"
}
PS1='$(precmd)$USER@$HOSTNAME:${PWD:-?} '"$PS1 "
export HOME HOSTNAME MKSH PS1 SHELL TERM USER
alias l='ls'
alias la='l -a'
alias ll='l -l'
alias lo='l -a -l'

for p in ~/.bin; do
    [[ -d $p/. ]] || continue
    [[ :$PATH: = *:$p:* ]] || PATH=$p:$PATH
done

unset p

: place customisations above this line
like image 912
Kalle Richter Avatar asked Mar 25 '14 05:03

Kalle Richter


People also ask

What cool things can I do with adb?

ADB, Android Debug Bridge, is a command-line utility included with Google's Android SDK. ADB can control your device over USB from a computer, copy files back and forth, install and uninstall apps, run shell commands, and more.

How do I open adb from command prompt?

Open a command window in the folder by holding shift and right-clicking in an empty spot in the folder and selecting "Open command prompt/PowerShell here" in the menu. Then you can start using ADB — connect your phone and try . ADB devices to see if it's working. A list with attached devices should show up.

What is adb shell commands?

Android Debug Bridge (adb) is a versatile command-line tool that lets you communicate with a device. The adb command facilitates a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.


1 Answers

You could change your PS1 prompt to be something smaller with the line:

PS1="> "

but it'd probably be better to instead increase the width of your window with something like:

COLUMNS=150
like image 89
scottt Avatar answered Oct 09 '22 00:10

scottt