From: Christian Heller Date: Fri, 11 Dec 2015 01:06:29 +0000 (+0100) Subject: Replace bashistic shell dotfiles with POSIXy regularity. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/conditions?a=commitdiff_plain;h=9ac68d1cb7fdd3ee3baa6ebdb02c35d5f83b9717;p=config Replace bashistic shell dotfiles with POSIXy regularity. --- diff --git a/dotfiles_minimal/profile b/dotfiles_minimal/profile new file mode 100644 index 0000000..5a58435 --- /dev/null +++ b/dotfiles_minimal/profile @@ -0,0 +1,6 @@ +# Initialization for login shells. + +# Tell interactive shells to look in ~/.shinit for setup. +ENV=$HOME/.shinit +export ENV +. $ENV diff --git a/dotfiles_minimal/shinit b/dotfiles_minimal/shinit new file mode 100644 index 0000000..a5a9ee2 --- /dev/null +++ b/dotfiles_minimal/shinit @@ -0,0 +1,33 @@ +# Settings for interactive shells. + +# Fancy colors for ls. +alias ls="ls --color=auto" + +# Use vim as default editor for anything. +export VISUAL=vim +export EDITOR=$VISUAL + +# Colored prompt with username, hostname, date/time, directory. +colornumber=7 # Default to white if no color set via colornumber dotfile. +colornumber_file=~/.shinit_color +if [ -f $colornumber_file ]; then + colornumber=`cat $colornumber_file` +fi +tput_color="$(tput setaf $colornumber)$(tput bold)" +tput_reset="$(tput sgr0)" +# Bash confuses the line length when not told to not count escape sequences. +which_shell=`lsof -ap $$ -d txt | awk 'NR>1 {print $NF}'` +if [ "${which_shell#*'bash'}" != "$which_shell" ]; then + tput_color="\[$tput_color\]" + tput_reset="\[$tput_reset\]" +fi +PS1="${tput_color}["\$\(date\ +%Y-%m-%d/%H:%M:%S/%Z\)" $USER@$(hostname):"\$\(pwd\)"]$ $tput_reset" +PS2="${tput_color}> $tput_reset" +PS3="${tput_color}select: $tput_reset" +PS4="${tput_color}+ $tput_reset" + +# Add local additions. +local_shinit_file=~/.shinit_add +if [ -f $local_shinit_file ]; then + . $local_shinit_file +fi diff --git a/dotfiles_root/bashrc b/dotfiles_root/bashrc deleted file mode 100644 index 64ba97b..0000000 --- a/dotfiles_root/bashrc +++ /dev/null @@ -1,14 +0,0 @@ -# plomlompom's bashrc for non-login shells (root) - -# Fancy colors for ls. -alias ls="ls --color=auto" - -# Use vim as default editor for anything. -export VISUAL=vim -export EDITOR=$VISUAL - -# Red prompt with time. -PS1="\[\e[1;31m\][\\t \\u@\\h \\w]$\[\e[m\] " -PS2="\[\e[1;31m\]>\[\e[m\] " -PS3="\[\e[1;31m\]>\[\e[m\] " -PS4="\[\e[1;31m\]+\[\e[m\] " diff --git a/dotfiles_root/shinit_color b/dotfiles_root/shinit_color new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/dotfiles_root/shinit_color @@ -0,0 +1 @@ +1 diff --git a/dotfiles_user_minimal/bash_profile b/dotfiles_user_minimal/bash_profile deleted file mode 100644 index 17d538c..0000000 --- a/dotfiles_user_minimal/bash_profile +++ /dev/null @@ -1,3 +0,0 @@ -# initialization for login shells - -source ~/.bashrc diff --git a/dotfiles_user_server/bashrc b/dotfiles_user_server/bashrc deleted file mode 100644 index 2409091..0000000 --- a/dotfiles_user_server/bashrc +++ /dev/null @@ -1,17 +0,0 @@ -# plomlompom's bashrc for non-login shells - -# Fancy colors for ls. -alias ls="ls --color=auto" - -# Use vim as default editor for anything. -export VISUAL=vim -export EDITOR=$VISUAL - -# Wrapper for weechat to force local config file on it anew on each run. -alias weechat="~/config/bin/weechat-wrapper.sh" - -# Blue prompt with time. -PS1="\[\e[1;34m\][\\t \\u@\\h \\w]$\[\e[m\] " -PS2="\[\e[1;34m\]>\[\e[m\] " -PS3="\[\e[1;34m\]>\[\e[m\] " -PS4="\[\e[1;34m\]+\[\e[m\] " diff --git a/dotfiles_user_server/shinit_add b/dotfiles_user_server/shinit_add new file mode 100644 index 0000000..02d6a99 --- /dev/null +++ b/dotfiles_user_server/shinit_add @@ -0,0 +1,4 @@ +# Server-specific .shinit additions. + +# Wrapper for weechat to force local config file on it anew on each run. +alias weechat="~/config/bin/weechat-wrapper.sh" diff --git a/dotfiles_user_server/shinit_color b/dotfiles_user_server/shinit_color new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/dotfiles_user_server/shinit_color @@ -0,0 +1 @@ +4 diff --git a/dotfiles_user_thinkpad/bashrc b/dotfiles_user_thinkpad/bashrc deleted file mode 100644 index 5cdcf22..0000000 --- a/dotfiles_user_thinkpad/bashrc +++ /dev/null @@ -1,14 +0,0 @@ -# plomlompom's bashrc for non-login shells - -# Fancy colors for ls. -alias ls="ls --color=auto" - -# Use vim as default editor for anything. -export VISUAL=vim -export EDITOR=$VISUAL - -# Blue prompt with time. -PS1="\[\e[1;32m\][\\t \\u@\\h \\w]$\[\e[m\] " -PS2="\[\e[1;32m\]>\[\e[m\] " -PS3="\[\e[1;32m\]>\[\e[m\] " -PS4="\[\e[1;32m\]+\[\e[m\] " diff --git a/dotfiles_user_thinkpad/shinit_color b/dotfiles_user_thinkpad/shinit_color new file mode 100644 index 0000000..0cfbf08 --- /dev/null +++ b/dotfiles_user_thinkpad/shinit_color @@ -0,0 +1 @@ +2 diff --git a/symlink.sh b/symlink.sh index e2f614f..fabee57 100755 --- a/symlink.sh +++ b/symlink.sh @@ -2,12 +2,16 @@ set -x +dir_minimal=~/config/dotfiles_minimal dir_user_minimal=~/config/dotfiles_user_minimal dir_user_thinkpad=~/config/dotfiles_user_thinkpad dir_user_server=~/config/dotfiles_user_server dir_root=~/config/dotfiles_root homedir=`echo ~` find ~ -lname $homedir'/config/*' -delete +for file in `ls $dir_minimal`; do + ln -fs $dir_minimal/$file ~/.$file +done for file in `ls $dir_user_minimal`; do ln -fs $dir_user_minimal/$file ~/.$file done