Browse Source

Disable all customization while inside a nix-shell

Some of my settings caused weird issues inside a nix-shell.
master
Peter J. Jones 11 months ago
parent
commit
5a51de2762
Signed by: Peter Jones <pjones@devalot.com> GPG Key ID: 9DAFAA8D01941E49
1 changed files with 53 additions and 62 deletions
  1. 53
    62
      bashrc

+ 53
- 62
bashrc View File

@@ -1,75 +1,66 @@
#!/bin/bash

################################################################################
# Shell settings:
set -o notify
shopt -s autocd
shopt -s cmdhist
shopt -s dotglob
shopt -s extglob
shopt -s failglob
shopt -s globstar
shopt -s histappend
shopt -s histreedit
shopt -s histverify
shopt -s xpg_echo
# The rest of this file should only be used when I'm not using nix-shell:
if [ -z "$NIX_BUILD_TOP" ]; then

################################################################################
# Environment variables:
export VIRSH_DEFAULT_CONNECT_URI="qemu:///system"
export GPG_TTY=$(tty)
##############################################################################
# Interactive functions:
function get() {
curl -Lo "$(basename "$1")" "$1"
}

if type -t e > /dev/null ; then
export EDITOR=e # Emacs!
else
export EDITOR=vi
fi
##############################################################################
# Prompt:
function indicate_nonzero_return() {
RETVAL=$?

################################################################################
# Aliases:
alias -- -='cd -'
alias ls='\ls --color=auto --group-directories-first'
alias lsa='ls -A'
alias l='\ls -lhF --color=auto --group-directories-first'
alias ll='l'
alias la='l -A'
alias df='df -hP'
alias p='ps -ewwopid,ppid,user,pcpu,vsz,rss,comm,args'
alias pg='p|egrep'
alias mrs='mr -d ~ status'
alias gpg=gpg2
alias nix-unstable='nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/tarball/nixpkgs-unstable'
if [ "$RETVAL" -ne 0 ]; then
echo "($RETVAL) "
fi
}

################################################################################
# Interactive functions:
function get() {
curl -Lo "$(basename "$1")" "$1"
}
##############################################################################
# Shell settings:
set -o notify
shopt -s autocd
shopt -s cmdhist
shopt -s dotglob
shopt -s extglob
shopt -s failglob
shopt -s globstar
shopt -s histappend
shopt -s histreedit
shopt -s histverify
shopt -s xpg_echo

################################################################################
# Prompt:
function indicate_nonzero_return() {
RETVAL=$?
##############################################################################
# Environment variables:
export VIRSH_DEFAULT_CONNECT_URI="qemu:///system"
export GPG_TTY=$(tty)

if [ "$RETVAL" -ne 0 ]; then
echo "($RETVAL) "
if type -t e > /dev/null ; then
export EDITOR=e # Emacs!
else
export EDITOR=vi
fi
}

function indicate_nix_shell_status() {
if [ -n "$NIX_BUILD_TOP" ]; then
echo "{ λ = nix; } "
fi
}
##############################################################################
# Aliases:
alias -- -='cd -'
alias ls='\ls --color=auto --group-directories-first'
alias lsa='ls -A'
alias l='\ls -lhF --color=auto --group-directories-first'
alias ll='l'
alias la='l -A'
alias df='df -hP'
alias p='ps -ewwopid,ppid,user,pcpu,vsz,rss,comm,args'
alias pg='p|egrep'
alias mrs='mr -d ~ status'
alias gpg=gpg2
alias nix-unstable='nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/tarball/nixpkgs-unstable'

function restore_prompt_after_nix_shell() {
if [ "$PS1" != "$PROMPT" ]; then
PS1=$PROMPT
PROMPT_COMMAND=""
fi
}

PROMPT_COMMAND=restore_prompt_after_nix_shell
PROMPT='\[\e[35m\][ \[\e[34m\]\u\[\e[31m\]@\[\e[32m\]\h\[\e[33m\]:\w \[\e[31m\]$(indicate_nonzero_return)\[\e[34m\]$(indicate_nix_shell_status)\[\e[35m\]]\[\e[m\]\n$ '
export PS1=$PROMPT
export PS2='> '
export PS1='\[\e[35m\][ \[\e[34m\]\u\[\e[31m\]@\[\e[32m\]\h\[\e[33m\]:\w \[\e[31m\]$(indicate_nonzero_return)\[\e[35m\]]\[\e[m\]\n$ '
export PS2='> '
fi

Loading…
Cancel
Save