What is the *nix command to view a user's default login shell
The canonical way to query the /etc/passwd file for this information is with getent
. You can parse getent
output with standard tools such as cut
to extract the user's login shell. For example:
$ getent passwd $LOGNAME | cut -d: -f7
/bin/bash
What is the equivalent to the bash/shell/UNIX-terminal command 'which' in Windows 10 PowerShell?
I use the Get-Command
cmdlet (short gcm
) for that:
gcm python
How to start a ZSH shell session with additional non-permanent aliases?
nix-shell
/nix develop
were originally designed for the specific use case of debugging Nixpkgs stdenv-based builds, which use bash.
If you want to support a different shell, I'd recommend to create a custom shell launcher script that you can run with nix run
. That gives you all the flexibility you need. That is, assuming you're ok with using experimental features.
Otherwise, you can create a script that fills the gap of nix run
: running nix-build
and exec
-ing its result, which is your custom shell launcher.
Alternatively, you can generate a script to be source
-d.
# zsh-functions.nix
{ pkgs ? import <nixpkgs> {} }:
let
inherit (pkgs) lib;
in
pkgs.writeText "functions.zsh" ''
PATH=${lib.makeBinPath [pkgs.hello]}:$PATH
hi(){
hello
}
''
zsh% eval "source $(nix-build zsh-functions.nix)"
Using ESS (Emacs Speaks Statistics) with nix
Open a regular shell buffer with M-x shell, run your nix-shell command there, then do M-x ess-remote and select R. ESS will then recognize this buffer as its interactive R session.
NB You need to run R before M-x ess-remote.
Running shell commands from Haskell in NixOS
Both your shell and callCommand
use the PATH
environment variable, so it seems like stack is changing that. It turns out that stack uses a pure nix shell by default, but you also want to access your user environment, which is 'impure'.
To quote the stack documenation
By default, stack will run the build in a pure Nix build environment (or shell), which means the build should fail if you haven't specified all the dependencies in the packages: section of the stack.yaml file, even if these dependencies are installed elsewhere on your system. This behaviour enforces a complete description of the build environment to facilitate reproducibility. To override this behaviour, add pure: false to your stack.yaml or pass the --no-nix-pure option to the command line.
Another solution is to add Emacs to nix.dependencies
in stack.yaml
(thanks @chepner). It has the benefit that some version of Emacs will always be available when a developer runs the tests, but that Emacs may not be the Emacs they want to use. You may be able to work around that using something like ~/.config/nixpkgs/config.nix
, unless they have configured their Emacs elsewhere, like the system configuration or perhaps a home manager. I'd prefer the simple but impure $PATH
solution.
Preserve bash history in multiple terminal windows
Add the following to your ~/.bashrc
:
# Avoid duplicates
HISTCONTROL=ignoredups:erasedups
# When the shell exits, append to the history file instead of overwriting it
shopt -s histappend
# After each command, append to the history file and reread it
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"
Unable to run user script in Unix server from Windows using C# and SSH.NET
Your question is pretty vague.
But first, I'd try is to add a path to the script. Either absolute (/home/user/script
) or relative (./script
).
*nix shells by default do not look for executables in the current working directory (home directory in this case). They find them only, if you have .
in your PATH
.
Note that the RunCommand
uses a non-interactive session. It may have a different environment (PATH
) than the interactive session you use in the SSH terminal. Different set of start-up scripts is used for interactive and non-interactive sessions.
Related Topics
How to Call Accept() for One Socket from Several Threads Simultaneously
Size() VS Ls -La VS Du -H Which One Is Correct Size
How to *Only* Get the Number of Bytes Available on a Disk in Bash
How to Increase the Scrollback Buffer in a Running Screen Session
How to Write a Linux Bash Script That Tells Me Which Computers Are on in My Lan
How to Start Docker Service in Ubuntu 16.04
How to Run Sudo Command in Winscp to Transfer Files from Windows to Linux
Using 'Find -Perm' to Find When a Permission Is Not Set
Truncating the First 100Mb of a File in Linux
How to Calculate the Mean of a Column
Run ASP.NET Core App Under Linux on Startup
Profiling a (Possibly I/O-Bound) Process to Reduce Latency
How to Analyse a Crash Dump File Using Gdb
How to Switch Linux Kernel Console After Boot Process
How to Create a Statically Linked Position Independent Executable Elf in Linux