]> git.phdru.name Git - dotfiles.git/blobdiff - .shellrc
.fvwmrc: Refactor many SetVolumeAndBrowser functions into one with parameters
[dotfiles.git] / .shellrc
index 892921c6beb5cbcc383929c5a5f0ddbf41456f7f..72c4a158f0fd434614bf0156a2b41f1a5d772908 100644 (file)
--- a/.shellrc
+++ b/.shellrc
@@ -40,23 +40,61 @@ case "$HOME" in
 esac
 
 if test -n "$KSH_VERSION" -o -n "$FCEDIT"; then
-    back() { cd - "$@"; }
-    j() { jobs; }
+    alias back='cd -'
+    alias j=jobs
 fi
 
-if test -n "$BASH_VERSION"; then
-    if [ -r "$HOME"/admin/prog/bash_prompt ]; then
-        . "$HOME"/admin/prog/bash_prompt
-        set_prompt
-        unset set_prompt
-    else
-        PS1="${debian_chroot:+($debian_chroot)}\u@\h:\W \$SHLVL\\$ "
-    fi
+# clear screen and history, logout
+alias clhlo='clear; cd; >$HISTFILE; unset HISTFILE; history -c; logout || exit'
+
+# cgmem_nice
+alias c3='cgmem_nice 300'
+alias c5='cgmem_nice 500'
+alias e3='exec cgmem_nice 300'
+alias e5='exec cgmem_nice 500'
+
+if [ -n "$STY" -a "$WINDOW" != 0 ]; then
+    #unset MAILCHECK everywhere except for the 1st GNU screen window
+    unset MAILCHECK
 fi
 
-# clear screen and history, logout
-chlo() { clear; cd; >$HISTFILE; unset HISTFILE; history -c; logout || exit; }
+if test -x /usr/bin/git >/dev/null 2>&1; then
+    # chdir to a directory
+    cdgitpath() {
+        if [ $# -ne 1 ]; then
+            echo "Usage: cdgitpath path_key" >&2
+            return 1
+        fi
+
+        path_key="$1"
+        if [ -z "$path_key" ]; then
+            echo "Usage: cdgitpath path_key" >&2
+            return 1
+        fi
 
+        path_url="`git config --get --path $path_key`"
+        if echo "$path_url" | grep -q '^file:/'; then
+            path_url="`echo \"$path_url\" | sed 's@^file:/\+@/@'`"
+        fi
+        cd "$path_url"
+    }
+
+    # See https://stackoverflow.com/a/77266926/7976758
+
+    cd_worktree() {
+        if [ $# -ne 1 ]; then
+            echo "Usage: cd_worktree <branch>" >&2
+            return 1
+        fi
+        path="$(git worktree list | grep -F "$1" | awk '{print $1}')"
+        if [ -n "$path" ]; then
+            cd "$path"
+        else
+            echo "Cannot find path for branch '$1'" >&2
+            return 1
+        fi
+    }
+fi
 
 include() {
     cfg="$1"
@@ -131,7 +169,7 @@ mc() {
         rc=1
     fi
 
-    unset MC_FOUND MC_PWD_FILE MC_SLOW MC_TMP_DIR MC_XTERM
+    unset wrapper MC_FOUND MC_PWD_FILE MC_SLOW MC_TMP_DIR MC_XTERM
 
     return $rc
 }
@@ -165,8 +203,16 @@ if which tmux >/dev/null 2>&1; then
 fi
 
 
+vim() {
+    command vim "$@"
+    rc=$?
+    cd "`cat \"$HOME/tmp/vim/cwd\"`" && /bin/rm "$HOME/tmp/vim/cwd" &&
+    return $rc
+}
+
+
 if [ "$SHLVL" -eq 1 ] && which startx >/dev/null 2>&1; then
-    X() { startx >> .Xserver.log 2>&1; cyr; rm -f .Xauthority; }
+    alias X='startx >> .Xserver.log 2>&1; cyr; /bin/rm -f .Xauthority'
 fi
 
-x() { exit; }
+alias x='logout || exit'