New answers tagged

1

It sounds like MacOS's Terminal has a feature where it extracts the current working directory from the process running in one tab (using /proc or similar) and uses it as the initial current working directory for a new tab. In this case, the process running in the first tab is script — which never bothers to change its current working directory, so new tabs ...


0

The current directory is simply: CWD="$(pwd)" ; echo "PWD === ${CWD}" ; Alternatively you may also in-line pass this eg: CWD="something" ./script log.txt The contents of the script containing: cat script #!/bin/bash if [ $CWD ] ; then echo "CWD Preset & == ${CWD}" ; else echo "CWD NOT SET... SETTING to: $(pwd)" ; CWD=$(pwd) ; fi ; You can ...


0

There is probably only one thing missing from your example, the option -f to flush the write each time. script -f >(while read;do date;echo "$REPLY";done >>session.log)


0

Sounds like ts, from moreutils. Lots of distros have it packaged. It just prepends timestamps to lines of input. Example use: $ while true; do sleep 1; echo hi; done | ts %s 1461198715 hi 1461198716 hi 1461198717 hi 1461198718 hi [ ... ]


0

this might be a partial solution, depending on your needs: if you include \d \D{} in your PS1 string, each command prompt will include the date and time. that will give you the time at which the previous command finished. in the simplest case, do PS1='\d \D{} $ ' do that after invoking script (or in your .bashrc or whatever) and you will get a ...



Top 50 recent answers are included