aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2018-06-04 23:10:09 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2018-06-04 23:10:09 +0300
commit6eb00d65d5732bbb025d573422adab5e3ca74dcc (patch)
treed118dbe74fa749a9293636098f89093449563871 /%HOME%
parentremove .profile (diff)
downloadlinux-home-6eb00d65d5732bbb025d573422adab5e3ca74dcc.tar.gz
linux-home-6eb00d65d5732bbb025d573422adab5e3ca74dcc.zip
attempt to organize stuff properly
bash-independent stuff should go to .profile, which is what I'm trying to do. I'm not sure about how correct all of this is, a few bashisms were ought to creep in.
Diffstat (limited to '')
-rw-r--r--%HOME%/.bash_profile3
-rw-r--r--%HOME%/.bash_utils/python.sh43
-rw-r--r--%HOME%/.bash_utils/ruby.sh20
-rw-r--r--%HOME%/.bashrc9
-rw-r--r--%HOME%/.profile61
5 files changed, 63 insertions, 73 deletions
diff --git a/%HOME%/.bash_profile b/%HOME%/.bash_profile
index b42f274..fe1b4b5 100644
--- a/%HOME%/.bash_profile
+++ b/%HOME%/.bash_profile
@@ -1,4 +1,5 @@
-[ -r "$HOME/.bashrc" ] && source "$HOME/.bashrc"
+[ -r "$HOME/.profile" ] && source "$HOME/.profile"
+[ -r "$HOME/.bashrc" ] && source "$HOME/.bashrc"
echo "Welcome to $( hostname )"
diff --git a/%HOME%/.bash_utils/python.sh b/%HOME%/.bash_utils/python.sh
deleted file mode 100644
index ff394d6..0000000
--- a/%HOME%/.bash_utils/python.sh
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (c) 2017 Egor Tensin <Egor.Tensin@gmail.com>
-# This file is part of the "Linux/Cygwin environment" project.
-# For details, see https://github.com/egor-tensin/linux-home.
-# Distributed under the MIT License.
-
-# This is a half-assed way to automatically add your user's pip binary
-# directory to $PATH.
-
-python_setup_() (
- set -o errexit -o nounset -o pipefail
-
- if [ "$#" -ne 1 ]; then
- echo "usage: ${FUNCNAME[0]} PYTHON_EXE"
- return 1
- fi
-
- local python="$1"
-
- local user_base
- user_base="$( "$python" -m site --user-base )"
-
- local user_bin="$user_base/bin"
- [ -d "$user_bin" ] || return 1
- echo "$user_bin"
-)
-
-python_setup() {
- local user_bin
-
- if command -v python3 &> /dev/null; then
- user_bin="$( python_setup_ python3 )" \
- && path_export "$user_bin"
- elif command -v python &> /dev/null; then
- user_bin="$( python_setup_ python )" \
- && path_export "$user_bin"
- fi
-}
-
-python_setup
-
-[ -r "$HOME/.pythonrc" ] && export PYTHONSTARTUP="$HOME/.pythonrc"
diff --git a/%HOME%/.bash_utils/ruby.sh b/%HOME%/.bash_utils/ruby.sh
deleted file mode 100644
index 8d0b74a..0000000
--- a/%HOME%/.bash_utils/ruby.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (c) 2016 Egor Tensin <Egor.Tensin@gmail.com>
-# This file is part of the "Linux/Cygwin environment" project.
-# For details, see https://github.com/egor-tensin/linux-home.
-# Distributed under the MIT License.
-
-ruby_setup() {
- local user_dir
- local bin_dir
-
- command -v ruby &> /dev/null \
- && command -v gem &> /dev/null \
- && user_dir="$( ruby -e 'puts Gem.user_dir' )" \
- && export GEM_HOME="$user_dir" \
- && bin_dir="$( ruby -e 'puts Gem.bindir' )" \
- && path_export "$bin_dir"
-}
-
-ruby_setup
diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc
index b23fc09..3ba8086 100644
--- a/%HOME%/.bashrc
+++ b/%HOME%/.bashrc
@@ -78,17 +78,8 @@ if os_is_cygwin; then
alias ming++='x86_64-w64-mingw32-g++'
fi
-if command -v vim > /dev/null 2>&1; then
- export EDITOR=vim
-elif command -v nano > /dev/null 2>&1; then
- export EDITOR=nano
-fi
-
# I've bumped into this on Linux Mint: Ctrl+S causes my terminal to freeze
# completely (Ctrl+Q is a temporary escape, stty is the cure).
os_is_cygwin \
|| command -v stty > /dev/null 2>&1 \
&& stty -ixon
-
-command -v path_export > /dev/null 2>&1 \
- && path_export "$HOME/.local/bin"
diff --git a/%HOME%/.profile b/%HOME%/.profile
new file mode 100644
index 0000000..401947b
--- /dev/null
+++ b/%HOME%/.profile
@@ -0,0 +1,61 @@
+if command -v vim > /dev/null 2>&1; then
+ export EDITOR=vim
+elif command -v nano > /dev/null 2>&1; then
+ export EDITOR=nano
+fi
+
+path_export() {
+ local path
+ for path; do
+ case "${PATH-}" in
+ "$path") continue ;;
+ *":$path") continue ;;
+ "$path:"*) continue ;;
+ *":$path:"*) continue ;;
+ esac
+ export PATH="$path:${PATH-}"
+ done
+}
+
+path_export "$HOME/.local/bin"
+
+# Ruby-specific stuff
+
+# This is a half-assed way to automatically add your user's gem binary
+# directory to $PATH (also setting GEM_HOME).
+
+ruby_setup() {
+ local user_dir
+ local bin_dir
+
+ command -v ruby > /dev/null 2>&1 \
+ && command -v gem > /dev/null 2>&1 \
+ && user_dir="$( ruby -e 'puts Gem.user_dir' )" \
+ && export GEM_HOME="$user_dir" \
+ && bin_dir="$( ruby -e 'puts Gem.bindir' )" \
+ && path_export "$bin_dir"
+}
+
+ruby_setup
+
+# Python-specific stuff
+
+# This is a half-assed way to automatically add your user's pip binary
+# directory to $PATH.
+
+python_setup() {
+ local python
+ local user_base
+ for python; do
+ command -v "$python" > /dev/null 2>&1 \
+ && user_base="$( "$python" -m site --user-base )" \
+ && [ -d "$user_base/bin" ] \
+ && path_export "$user_base/bin" \
+ && continue
+ break
+ done
+}
+
+python_setup python3 python
+
+[ -r "$HOME/.pythonrc" ] && export PYTHONSTARTUP="$HOME/.pythonrc"