Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:[ HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 ]
$ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwdOr just:
/home/lpitcher
$ echo ~
In article <sl9ckq$nc9$1...@dont-email.me>,
Lew Pitcher <lew.p...@digitalfreehold.ca> wrote:
On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:
On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
I've written the following Emacs package debug script which can beWell, you /could/ derive your version of HOME differently. Yes, let's go >>> with that.
run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
```emacs-lisp
#!/usr/bin/env bash
:;# $ realpath init.el
:;# /home/werner/.emacs.d/debug/.emacs.d/init.el
:; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 >>> > /usr/local/bin/emacs -- "$@"; exit
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(use-package company
:demand t
:hook
(after-init . global-company-mode))
```
But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
variable setting. How to solve this dilemma?
Initially, HOME is derived from the 6th field in the user's
/etc/passwd entry. You could
- use whoami(1) to determine the username
- use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd >>> and extract the home directory of the selected username
- use that extracted home directory value to set your HOME variable
Do you mean this one?
$ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
/home/werner
Sure. OrOr just:
$ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd /home/lpitcher
$ echo ~
and
$ echo ~lpitcher
--
People sleep peaceably in their beds at night only because rough
men stand ready to do violence on their behalf.
George Orwell
In article <sl9ckq$nc9$1@dont-email.me>,
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:
On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
I've written the following Emacs package debug script which can beWell, you /could/ derive your version of HOME differently. Yes, let's go >>>> with that.
run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
```emacs-lisp
#!/usr/bin/env bash
:;# $ realpath init.el
:;# /home/werner/.emacs.d/debug/.emacs.d/init.el
:; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 >>>> > /usr/local/bin/emacs -- "$@"; exit
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(use-package company
:demand t
:hook
(after-init . global-company-mode))
```
But the `proxychains-ng-socks5` wrapper script relies on the normal HOME >>>> > variable setting. How to solve this dilemma?
Initially, HOME is derived from the 6th field in the user's
/etc/passwd entry. You could
- use whoami(1) to determine the username
- use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd >>>> and extract the home directory of the selected username
- use that extracted home directory value to set your HOME variable
Do you mean this one?
$ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
/home/werner
Sure. Or
$ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
/home/lpitcher
Or just:
$ echo ~
and
$ echo ~lpitcher
On Tue, 26 Oct 2021 18:37:52 +0000, Kenny McCormack wrote:
In article <sl9ckq$nc9$1@dont-email.me>,
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:
On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
I've written the following Emacs package debug script which can be >>>>> > run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:Well, you /could/ derive your version of HOME differently. Yes, let's go >>>>> with that.
```emacs-lisp
#!/usr/bin/env bash
:;# $ realpath init.el
:;# /home/werner/.emacs.d/debug/.emacs.d/init.el
:; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 >>>>> > /usr/local/bin/emacs -- "$@"; exit
;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)
(use-package company
:demand t
:hook
(after-init . global-company-mode))
```
But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
variable setting. How to solve this dilemma?
Initially, HOME is derived from the 6th field in the user's
/etc/passwd entry. You could
- use whoami(1) to determine the username
- use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd >>>>> and extract the home directory of the selected username
- use that extracted home directory value to set your HOME variable
Do you mean this one?
$ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
/home/werner
Sure. Or
$ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
/home/lpitcher
Or just:
$ echo ~
and
$ echo ~lpitcher
If $HOME is not reliably set, then ~ is unlikely to be either.
Witness:
10:27 $ echo $HOME
/home/lpitcher
10:27 $ echo ~
/home/lpitcher
Both $HOME and ~ point at my home directory
But now, I change $HOME to point somewhere else
10:27 $ HOME=/var/some/directory
10:28 $ echo $HOME
/var/some/directory
And, lo and behold, ~ changes as well
10:28 $ echo ~
/var/some/directory
So, if the OP can't depend on $HOME to point to the proper
directory (hence, his asking how to derive the home directory)
then he can't depend on ~ either.
HTH
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 365 |
Nodes: | 16 (3 / 13) |
Uptime: | 25:20:31 |
Calls: | 7,748 |
Files: | 12,888 |
Messages: | 5,740,148 |