General TC > Programming & Scripting - Unofficial
path2.sh aka "$( which $1 )"
(1/1)
mocore:
a script for those to lazy or board of repeatedly typing
nano $(which _some_script_in_path_ )
ect ..
--- Code: ---#path2.sh
# echo(default) full path to any script in $PATH ,
# optionally prefix the cmd_path with other command eg nano/cat/file ect
[ -z $dbg ] || set -x ; #
_cmd=$1
_run=${2-echo} # set default to echo
[ $# -eq 1 ] && shift # enable extra args
[ $# -eq 2 ] && shift 2
cmd_path=$( which $_cmd )
# run cmd passing args
$_run $cmd_path "$@"
--- End code ---
--- Quote ---#eg
# edit this(or any other) script ( in $PATH )
# path2.sh path2.sh nano
#- print this script
# path2.sh path2.sh cat
#- debug this script
# path2.sh path2.sh "sh -x"
#- WTF
# export dbg=y path2.sh path2.sh "exec" path2.sh cat
--- End quote ---
:o
(obviously) simpler yet also
similar in some ways (prefixing & arg juggling ) to : ' a shell repl function ' https://forum.tinycorelinux.net/index.php/topic,26193.0.html
aka * https://github.com/mchav/with - Command prefixing for continuous workflow using a single tool.
*mchav/with requires bash
mocore:
for those who are forgetful/unfamiliar with the concept
its useful because it helps u type less ;)
--- Quote --- The PATH variable makes it easy to run commonly used programs located in their own folders.
--- End quote ---
https://en.wikipedia.org/wiki/PATH_(variable)
from a topic about
modifying PATH in core
--- Quote from: Rich on December 17, 2019, 10:13:32 AM ---Hi PDP-8
Take a look inside ~/.profile for adding paths.
--- End quote ---
on a bit of a tangent wrt .profile
--- Quote from: Rich on February 09, 2019, 02:21:40 PM ---Looks like additions to .profile probably need to be added above this section of the file in order to be seen:
--- Code: ---TERMTYPE=`/usr/bin/tty`
[ ${TERMTYPE:5:3} == "tty" ] && (
[ ! -f /etc/sysconfig/Xserver ] ||
[ -f /etc/sysconfig/text ] ||
[ -e /tmp/.X11-unix/X0 ] ||
startx
)
--- End code ---
--- End quote ---
generally on the topic
https://unix.stackexchange.com/questions/227989/complete-view-of-where-the-path-variable-is-set-in-bash
Navigation
[0] Message Index
Go to full version