Use vim for manpages and infopages.
[profile.git] / .profile.d / man.bashrc
diff --git a/.profile.d/man.bashrc b/.profile.d/man.bashrc
new file mode 100644 (file)
index 0000000..229a5f2
--- /dev/null
@@ -0,0 +1,24 @@
+# $Id$
+#
+# Use vim for manpages and infopages.
+# Requires vim 5+ and info.vim plugin.
+#
+
+vimmajor=$(vim --help 2>&1 | head -n 1 | sed 's/^VIM[^0-9]*\([0-9]*\)\..*/\1/')
+
+function vman() {
+  vim -c "runtime ftplugin/man.vim" -c "Man ${1-man}" \
+      -c "set nolist noruler ls=0" +"wincmd o"
+}
+
+function vinfo() {
+  vim -c "Info ${1-info}" \
+      -c "set nolist noruler ls=0" +"wincmd o"
+}
+
+if [ ! -z "$vimmajor" -a $vimmajor -gt 4 ]; then
+  alias man=vman
+  alias info=vinfo
+fi
+
+unset vimmajor