dotfiles

My personal dotfiles
git clone git://pcardensab.com/dotfiles
Log | Files | Refs | Submodules | README

hardmode.sh (1815B)


      1 # shellcheck shell=sh
      2 
      3 cd() {
      4 	echo "Use pushd!"
      5 	return 1
      6 }
      7 
      8 pwd() {
      9 	echo "Use dirs [-v]"
     10 	return 1
     11 }
     12 
     13 man() {
     14 	case $1 in
     15 	-* | [0-9]* | n)
     16 		command man "$@"
     17 		;;
     18 	*)
     19 		echo "Specify section"
     20 		return 1
     21 		;;
     22 	esac
     23 }
     24 
     25 git() {
     26 	if [ "$1" = "--git-dir" ]; then
     27 		_git_dir="$2"
     28 		shift 2
     29 	fi
     30 	if [ "$1" = "--work-tree" ]; then
     31 		_work_tree="$2"
     32 		shift 2
     33 	fi
     34 	if [ "$1" = "-C" ]; then
     35 		_c="$2"
     36 		shift 2
     37 	fi
     38 
     39 	if [ "$1" = "checkout" ]; then
     40 		echo "Use"
     41 		echo " - git checkout-index -fu"
     42 		echo " - git read-tree --reset -u"
     43 	elif [ "$1" = "reset" ]; then
     44 		echo "Use"
     45 		echo " - git read-tree -mu"
     46 		echo " - git read-tree -m"
     47 		echo " - git update-index --add --remove \
     48 --cacheinfo 100644 sha1 filename"
     49 	elif [ "$1" = "status" ] && [ $# = 1 ]; then
     50 		echo "Use"
     51 		echo " - git diff-index --cached HEAD"
     52 		echo " - git diff-files"
     53 		echo " - git ls-files --exclude-standard -o"
     54 		echo " - git status -bs"
     55 	elif [ "$1" = "log" ]; then
     56 		echo "Use"
     57 		echo " - git rev-list HEAD"
     58 	else
     59 		if [ -n "${_git_dir}" ]; then
     60 			set -- --git-dir "${_git_dir}" "$@"
     61 		fi
     62 		if [ -n "${_work_tree}" ]; then
     63 			set -- --work-tree "${_work_tree}" "$@"
     64 		fi
     65 		if [ -n "${_c}" ]; then
     66 			set -- -C "${_c}" "$@"
     67 		fi
     68 		unset _git_dir _work_tree _c
     69 		command git "$@"
     70 		return $?
     71 	fi
     72 	return 1
     73 }
     74 
     75 tmux() {
     76 	if [ $# = 0 ]; then
     77 		echo "Don't use tmux without arguments"
     78 		return 1
     79 	fi
     80 
     81 	if [ "$1" = "new-session" ] || [ "$1" = "new" ] && [ "$2" != "-c" ]; then
     82 		echo "Specify the working directory."
     83 		return 1
     84 	fi
     85 
     86 	command tmux "$@"
     87 }
     88 
     89 # shellcheck disable=SC2016
     90 PROMPT_COMMAND+=(
     91 	'{
     92 		[[ -z "$TMUX" ]] &&
     93 		[[ $TERM != tmux-* ]] &&
     94 		[[ "$ASCIINEMA_REC" != 1 ]] && {
     95 			[[ -n "$DISPLAY" ]] ||
     96 			[[ -n "$TERMUX_VERSION" ]] ||
     97 			[[ -n "$MSYSTEM" ]]
     98 		}
     99 	} && {
    100 		[[ -z "$FIRST_COMMAND" ]] &&
    101 		FIRST_COMMAND=1 || exit;
    102 	}'
    103 )