]> code.delx.au - dotfiles/blobdiff - .bashrc
gnome-setup.sh
[dotfiles] / .bashrc
diff --git a/.bashrc b/.bashrc
index d78b919c15b1e33e6767cfae6c44d37524f92211..300ab1dd8795c0c21d1053b2dd5f1c7532ae14d2 100644 (file)
--- a/.bashrc
+++ b/.bashrc
@@ -15,19 +15,32 @@ fi
 # Add ~/bin and subdirs to PATH if needed
 while read -r p; do
     echo "$PATH" | tr ':' '\n' | grep -qxF "$p" || PATH="${p}:$PATH"
-done < <(find -L ~/bin -maxdepth 1 -type d 2> /dev/null)
+done < <(find -L ~/bin -depth -maxdepth 1 -type d 2> /dev/null)
 
 # Set environment variables, eg EMAIL, LANG
 eval "$(cat 2> /dev/null /etc/default/locale /etc/locale.conf ~/.config/environment.d/*.conf | awk -F= '/^[^# ]/ {print $0 ";export " $1}')"
 
+# Look for XDG_RUNTIME_DIR
+if [ -z "$XDG_RUNTIME_DIR" ] && [ -d "/run/user/$(id -u)" ]; then
+    XDG_RUNTIME_DIR="/run/user/$(id -u)"
+    export XDG_RUNTIME_DIR
+fi
+
 # Pick up SSH agent socket
 if [ -z "$SSH_AUTH_SOCK" ]; then
-    if [ -r ~/.ssh-agent.env ]; then
-        source ~/.ssh-agent.env
-    else
-        SSH_AUTH_SOCK="/run/user/$(id -u)/keyring/ssh"
-        export SSH_AUTH_SOCK
-    fi
+    for p in keyring/ssh gcr/ssh openssh_agent; do
+        SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/$p"
+        if [ -S "$SSH_AUTH_SOCK" ]; then
+            export SSH_AUTH_SOCK
+            break
+        fi
+    done
+fi
+
+# Look for DBUS
+if [ -z "$DBUS_SESSION_BUS_ADDRESS" ] && [ -S "/run/user/$(id -u)/bus" ]; then
+    DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/$(id -u)/bus"
+    export DBUS_SESSION_BUS_ADDRESS
 fi
 
 
@@ -165,7 +178,7 @@ trap print_exit_code ERR
 
 # This prevents long/ugly command lines from showing up in xterm titles
 function aliasf {
-    eval "function $1 { $2 \$@; }"
+    eval "function $1 { $2 \"\$@\"; }"
 }
 
 
@@ -173,11 +186,14 @@ function aliasf {
 # ls aliases and colours #
 ##########################
 
-# GNU ls colours
-eval "$(TERM=xterm dircolors 2> /dev/null)"
-
-# BSD ls colours
-export LSCOLORS="ExFxCxDxBxEGEDABAGACAD"
+if command -v dircolors &> /dev/null; then
+    # GNU ls colours
+    eval "$(dircolors)"
+    LS_COLORS+=':ow=30;42'
+else
+    # BSD ls colours
+    export LSCOLORS="ExFxCxDxBxEGEDABAGACAD"
+fi
 
 # Lets find the ls
 if ls --color=auto -v &> /dev/null; then
@@ -202,7 +218,7 @@ alias _psresources='ps -wAo pid,user,%cpu,%mem,stat,start,time,args'
 if [ "$(uname)" = "Linux" ]; then
     aliasf pscpu '_psresources --sort -%cpu|less -S'
     aliasf psmem '_psresources --sort -%mem|less -S'
-    aliasf pstree 'ps --forest -weo pid,user:16,args --sort start_time|less -S'
+    aliasf pstree 'ps --forest -weo pid,user:16,args|less -S'
     aliasf pstime 'ps -wAo pid,user,lstart,args --sort start_time|less -S'
 else
     aliasf pscpu '_psresources -r|less -S'
@@ -226,12 +242,8 @@ aliasf sudosu 'sudo su -l -s /bin/bash'
 aliasf python 'PYTHONSTARTUP=~/.pythonrc.py python3'
 aliasf webshare 'python3 -mhttp.server'
 
-if ! command -v pbcopy &> /dev/null; then
-    alias pbcopy='xsel --clipboard --input'
-    alias pbcopym='xsel --input'
-    alias pbpaste='xsel --clipboard --output'
-    alias pbpastem='xsel --output'
-fi
+export EDITOR='vim'
+aliasf edit "$EDITOR"
 
 # man with coloured headings and a terminal title
 function man {
@@ -262,25 +274,6 @@ function ssh_unsafe {
 }
 
 
-##################
-# Editor aliases #
-##################
-
-if emacsclient --version &> /dev/null; then
-    export ALTERNATE_EDITOR='vim'
-    export EDITOR='emacsclient --tty'
-
-    if [[ "$TERM" == screen* ]]; then
-        aliasf edit 'emacsclient --tty'
-    else
-        aliasf edit 'emacsclient --create-frame --no-wait'
-    fi
-else
-    export EDITOR='vim'
-    aliasf edit 'vim'
-fi
-
-
 #########################
 # Optional local config #
 #########################
@@ -296,7 +289,7 @@ fi
 function print_title_prompt {
     printf '\e]0;bash:%s (%s)\a' \
         "${PWD/$HOME/\~}" \
-        "$(hostname -s)"
+        "$(cat /etc/hostname)"
 
     if [[ "$TERM" == screen* ]]; then
         printf '\ekbash\e\\'
@@ -319,10 +312,11 @@ PROMPT_COMMAND=prompt_command
 # bashrc to avoid running the trap on commands in the bashrc
 function print_title_exec {
     [ "$BASH_COMMAND" = "$PROMPT_COMMAND" ] && return
+    [ "$BASH_COMMAND" = "__vte_osc7" ] && return
 
     printf '\e]0;%s (%s)\a' \
         "$(tr -cd '[:graph:] ' <<< "$BASH_COMMAND")" \
-        "$(hostname -s)"
+        "$(cat /etc/hostname)"
 
     if [[ "$TERM" == screen* ]]; then
         printf '\ek%s\e\\' \