.profile 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. #!/bin/sh
  2. ## This file should be automatically sourced by the login manager or Bash if
  3. ## .bash_profile does not exist. If this file is not automatically sourced,
  4. ## do it from the shell config to me sure it applies to TTY as well.
  5. ## Preliminary path definitions. For security reasons (and bad programming
  6. ## assumptions) you should always append entries to PATH, not prepend them.
  7. appendpath () {
  8. [ $# -eq 2 ] && PATHVAR=$2 || PATHVAR=PATH
  9. [ -d "$1" ] || return
  10. eval echo \$$PATHVAR | grep -q "\(:\|^\)$1\(:\|$\)" && return
  11. eval export $PATHVAR="\$$PATHVAR:$1"
  12. }
  13. prependpath () {
  14. [ $# -eq 2 ] && PATHVAR=$2 || PATHVAR=PATH
  15. [ -d "$1" ] || return
  16. eval echo \$$PATHVAR | grep -q "\(:\|^\)$1\(:\|$\)" && return
  17. eval export $PATHVAR="$1:\$$PATHVAR"
  18. }
  19. ## Custom paths
  20. export PERSONAL="$HOME/projects/personal"
  21. ## Cask
  22. appendpath "$HOME/.cask/bin"
  23. ## Guix
  24. export GUIX_DISTRO_AGE_WARNING=1m
  25. ## WARNING: GUIX_PACKAGE_PATH is deprecated in favor of channels.
  26. # if command -v guix >/dev/null 2>&1; then
  27. # export GUIX_PACKAGE_PATH="$HOME/.guix-packages"
  28. # fi
  29. for i in ~/.guix-extra-profiles/*; do
  30. profile=$i/$(basename "$i")
  31. if [ -f "$profile"/etc/profile ]; then
  32. GUIX_PROFILE="$profile" ; . "$profile"/etc/profile
  33. export MANPATH="$profile"/share/man:$MANPATH
  34. export INFOPATH="$profile"/share/info:$INFOPATH
  35. export XDG_DATA_DIRS="$profile"/share:$XDG_DATA_DIRS
  36. export XDG_CONFIG_DIRS="$profile"/etc/xdg:$XDG_CONFIG_DIRS
  37. fi
  38. unset profile
  39. done
  40. ## progress
  41. if command -v progress >/dev/null 2>&1; then
  42. export PROGRESS_ARGS="-a .emacs-$(emacs -Q --batch --eval '(message emacs-version)' 2>&1)-real"
  43. fi
  44. ## Use this to override system executables.
  45. prependpath "$PERSONAL/hackpool"
  46. ## Last PATH entries.
  47. appendpath "$HOME/.local/bin"
  48. ## Remove less history.
  49. LESSHISTFILE='-'
  50. ## Manpage.
  51. export MANWIDTH=80
  52. ## SSH-Agent
  53. ## Set SSH to use gpg-agent
  54. unset SSH_AGENT_PID
  55. if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then
  56. export SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)"
  57. fi
  58. # Set GPG TTY
  59. export GPG_TTY=$(tty)
  60. # Refresh gpg-agent tty in case user switches into an X session
  61. gpg-connect-agent updatestartuptty /bye >/dev/null
  62. ## Linux specific
  63. if [ "$(uname -o)" = "GNU/Linux" ] ; then
  64. ## Startup error log.
  65. log_dmesg="$(dmesg | grep -i error)"
  66. [ -n "$log_dmesg" ] && echo "$log_dmesg" > "$HOME/errors-dmesg.log" || rm "$HOME/errors-dmesg.log" 2>/dev/null
  67. unset log_dmesg
  68. fi
  69. ## Wine DLL overrides.
  70. ## Remove the annoying messages for Mono and Gecko.
  71. export WINEDLLOVERRIDES="mscoree,mshtml="
  72. ## Do not create desktop links or start menu entries.
  73. export WINEDLLOVERRIDES="$WINEDLLOVERRIDES;winemenubuilder.exe=d"
  74. ## Default text editor
  75. ## 'em' is a custom wrapper for emacsclient. See '.bin/em'.
  76. ## VISUAL is given priority by some programs like Mutt. This way we can separate
  77. ## editors that wait from those that don't.
  78. for i in emacsclient em emacs zile vim nano vi; do
  79. command -v $i >/dev/null 2>&1 && export EDITOR=$i && break
  80. done
  81. GIT_EDITOR="$EDITOR"
  82. VISUAL="$EDITOR"
  83. [ "$GIT_EDITOR" = em ] && GIT_EDITOR=emc
  84. [ "$VISUAL" = em ] && VISUAL=emw
  85. export GIT_EDITOR
  86. export VISUAL
  87. ## Hook. Should be sourced last
  88. [ -f ~/.profile_hook ] && . ~/.profile_hook
  89. ## Hook example
  90. #
  91. # export CPPFLAGS=-I$HOME/local/usr/include
  92. # export LDFLAGS=-L$HOME/local/usr/lib
  93. #
  94. # appendpath "$HOME/local/usr/lib/python2.7/dist-packages/" PYTHONPATH
  95. # export LUA_CPATH="$HOME/local/usr/lib/lib?.so;$(lua -e "print(package.cpath)")"
  96. #
  97. # umask 077
  98. ## End: Source .bashrc. The rc file should guard against non-interactive shells.
  99. [ "$(ps -o comm= $$)" != bash ] && return
  100. [ -f ~/.bashrc ] && . ~/.bashrc
  101. [ -z "$DISPLAY" ] && [ "$(tty)" = '/dev/tty1' ] && exec xinit -- vt01