I've written the following Emacs package debug script which can be
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?
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`:
```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 companyWell, you /could/ derive your version of HOME differently. Yes, let's go
: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?
with that.
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
But the `proxychains-ng-socks5` wrapper script relies on the normal
HOME variable setting. How to solve this dilemma?
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
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?
with that.
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
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
Some software uses /etc/passwd instead of the HOME variable.
It's a bug.
Possibly you can inspect 'proxychains-ng-socks5' if it's an script and
fix the bug yourself.
That bug was very common in the past. Fortunately nowadays most
software has fixed it. Ivan Shmakov commented about that in
comp.emacs a pair of years ago:
Ivan Shmakov <iv...@siamics.net> on comp.emacs
Message-ID: <8736wyx2...@violet.siamics.net>
Unfortunately, some software refers to passwd(5) data directly
instead, leaving no way for the user to override the home
directory location. In particular, this was the behavior (IIRC)
of programs based on older Glib versions. And I vaguely recall
that Emacs might have been affected as well.
On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:[...]
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
FWIW, from bash(1):
Shell Variables
The following variables are set by the shell:
...
HOME The home directory of the current user; the default argument for
the cd builtin command. The value of this variable is also used
when performing tilde expansion.
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:[...]
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
FWIW, from bash(1):
Shell Variables
The following variables are set by the shell:
...
HOME The home directory of the current user; the default argument for
the cd builtin command. The value of this variable is also used
when performing tilde expansion.
On the other hand, ~username, as opposed to just ~, does not depend on
$HOME. It does a lookup in /etc/passwd or whatever the system's
equivalent is.
$ echo $HOME ~ ~kst
/home/kst /home/kst /home/kst
$ HOME=/tmp
$ echo $HOME ~ ~kst
/tmp /tmp /home/kst
$ eval echo ~$USER
/home/kst
$ eval echo ~$(whoami)
/home/kst
$
On Wed, 27 Oct 2021 10:19:22 -0700, Keith Thompson wrote:
Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:[...]
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
FWIW, from bash(1):
Shell Variables
The following variables are set by the shell:
...
HOME The home directory of the current user; the default argument for
the cd builtin command. The value of this variable is also used
when performing tilde expansion.
On the other hand, ~username, as opposed to just ~, does not depend on $HOME. It does a lookup in /etc/passwd or whatever the system's
equivalent is.
$ echo $HOME ~ ~kstThanks, Keith
/home/kst /home/kst /home/kst
$ HOME=/tmp
$ echo $HOME ~ ~kst
/tmp /tmp /home/kst
$ eval echo ~$USER
/home/kst
$ eval echo ~$(whoami)
/home/kst
$
I'm glad to have learned something new today.
Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:[...]
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
FWIW, from bash(1):On the other hand, ~username, as opposed to just ~, does not depend on
Shell Variables
The following variables are set by the shell:
...
HOME The home directory of the current user; the default argument for
the cd builtin command. The value of this variable is also used
when performing tilde expansion.
$HOME. It does a lookup in /etc/passwd or whatever the system's
equivalent is.
$ echo $HOME ~ ~kst
/home/kst /home/kst /home/kst
$ HOME=/tmp
$ echo $HOME ~ ~kst
/tmp /tmp /home/kst
$ eval echo ~$USER
/home/kst
$ eval echo ~$(whoami)
/home/kst
$
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 292 |
Nodes: | 16 (2 / 14) |
Uptime: | 203:39:49 |
Calls: | 6,617 |
Calls today: | 1 |
Files: | 12,168 |
Messages: | 5,316,470 |