dotfiles

Obligatory dotfiles repo
git clone git://git.danielmoch.com/dotfiles.git
Log | Files | Refs

commit 85fb1666b3b4230b2dca6e5ed2abca7e25056d59
parent 6e5f6cc9b4357f9367d1dde9b5fecc015c06b712
Author: Daniel Moch <daniel@danielmoch.com>
Date:   Mon, 16 Sep 2019 05:30:11 -0400

POSIX shells: Make them usable

Diffstat:
M.profile | 12++++++------
M.shrc | 46++++++++++++++++++++++++++--------------------
2 files changed, 32 insertions(+), 26 deletions(-)

diff --git a/.profile b/.profile @@ -5,19 +5,19 @@ if [ "$0" = "sh" -o "$0" = "-sh" ] then - HOSTNAME=`hostname | cut -d . -f 1` + HOSTNAME=`hostname | cut -d . -f 1`; export HOSTNAME ENV="$HOME/.shrc"; export ENV - printf "\033]0;${USER}@${HOSTNAME}\007" + printf "\033]0;${LOGNAME}@${HOSTNAME}\007" fi -if type vim > /dev/null 2>&1 +if type ed > /dev/null 2>&1 then - EDITOR=vim + EDITOR=ed else - EDITOR=vi + EDITOR=ex fi -VISUAL=$EDITOR +VISUAL=vi PAGER=less LESS="-FMRqX#10" export EDITOR VISUAL PAGER LESS diff --git a/.shrc b/.shrc @@ -6,39 +6,45 @@ set -o emacs -PS1="$LOGNAME@\h:\W\$ " +__ps1() { + echo -n $LOGNAME@$HOSTNAME: + if [ "$PWD" = "$HOME" ] + then + echo -n '~' + else + echo -n $(basename $PWD) + fi + + if type git > /dev/null 2>&1 + then + if git rev-parse --show-toplevel > /dev/null 2>&1 + then + echo " ($(git rev-parse --abbrev-ref HEAD))" + else + echo + fi + fi +} +PS1='$(__ps1)\$ ' export PS1 if type dircolors > /dev/null 2>&1 then - if [ -n "$SOURCE_DIRCOLORS" ] - then - eval `dircolors "$HOME/.dir_colors"` - unset SOURCE_DIRCOLORS - fi - alias ls="ls --color=auto" - LSCOLORPARAM="--color=auto" + alias ls="ls --color=never" + LSCOLORPARAM="--color=never" else - CLICOLOR=1 - LSCOLORS=ExFxBxDxCxegedabagacad - export CLICOLOR LSCOLORS LSCOLORPARAM="" fi +num() { + pr -tn "$1" | $PAGER +} + alias ll="ls $LSCOLORPARAM -l" alias la="ls $LSCOLORPARAM -A" alias lla="ls $LSCOLORPARAM -lA" unset LSCOLORPARAM -for cmd in pacman grep egrep fgrep -do - if type $cmd > /dev/null 2>&1 - then - alias $cmd="$cmd --color=auto" - fi -done -unset cmd - alias tas="tmux attach-session -t" alias tns="tmux new-session -s" alias tls="tmux list-sessions"