Prechádzať zdrojové kódy

Initial files for dotfiles repo

Sam Jaffe 9 rokov pred
commit
93874b0625
6 zmenil súbory, kde vykonal 351 pridanie a 0 odobranie
  1. 5 0
      bashrc
  2. 40 0
      complete-p4
  3. 19 0
      make_links.sh
  4. 69 0
      profile-p4
  5. 98 0
      profile-util
  6. 120 0
      tmux.conf

+ 5 - 0
bashrc

@@ -0,0 +1,5 @@
+
+if [[ -f ${HOME}/.profile-local ]]; then . ${HOME}/.profile-local; fi
+
+. ${HOME}/.profile-util
+

+ 40 - 0
complete-p4

@@ -0,0 +1,40 @@
+
+# - PERFORCE {{{ -
+
+  _p4commands() {
+    p4 help commands | sed -re "s/^\t+(\w+)\s+.+/\1/" | sed -re "s/^\s.*//"
+  }
+
+  _p4opened() {
+    p4 opened 2>/dev/null | sed -rn 's/.*\/(.*\..*)#.*/\1/p'
+  }
+
+
+  _complete_p4(){
+    local cur
+      cur=${COMP_WORDS[COMP_CWORD]}
+    prev=${COMP_WORDS[COMP_CWORD-1]}
+
+    case "$prev" in
+    p4|perf)
+      COMPREPLY=( $(_p4commands | grep -E "^$cur") );;
+
+    diff|revert|pd)
+      COMPREPLY=( $(_p4opened | grep -E "^$cur") );;
+
+    add|delete|edit|pe)
+#COMPREPLY=( $(ls | grep -v "$(p4opened | sed 's/\n/\|/')"));;
+      COMPREPLY=( $(uniq -u \
+            <( sort <(ls) <(_p4opened) ) \
+            | grep -E "^$cur" ) );;
+
+    *)
+      COMPREPLY=( $( compgen -f ${COMP_WORDS[COMP_CWORD]} ) );;
+
+    esac
+      return 0
+  }
+  complete -F _complete_p4 p4 perf pe pd
+
+# - }}} -
+

+ 19 - 0
make_links.sh

@@ -0,0 +1,19 @@
+#!/bin/bash
+
+main() {
+  local homedir=$(dirname $(readlink -f "${BASH_SOURCE}"))
+  cd "${homedir}"
+
+  # The files make_links.sh and README.md are not part of the 'dotfiles', but assistands
+  # TODO(sjaffe): Make it so a list can be embedded in this instead of enumeration
+  local files=( $( find -type f ! \( -name 'make_links.sh' -o -name 'README.md' \) | sed 's/.\///' ) )
+
+  for f in ${files[@]}; do
+    echo ~/.${f} "-->" ${homedir}/${f}
+    if [[ -f ~/.${f} ]]; then mv ~/.${f} ~/${f}.old; fi
+    ln -s ${homedir}/${f} ~/.${f}
+  done
+}
+
+main
+

+ 69 - 0
profile-p4

@@ -0,0 +1,69 @@
+export P4EDITOR=/home/user/wreed/bin/vim
+export P4DIFF="/home/user/wreed/bin/vim -d"
+export P4MERGE="/home/user/wreed/bin/vim -d"
+
+alias p4a="p4 add"
+alias p4e="p4 edit"
+alias p4r="p4 revert"
+alias p4s="p4 sync"
+alias p4d="p4 delete"
+alias p4o="p4 opened"
+alias p4c="p4 client"
+alias p4i="p4 integrate"
+alias p4grab="p4 diff -se | p4 -x - edit"
+alias p4reset="p4 diff -sr | p4 -x - revert"
+
+p4whose() {
+  if [[ $# -ne 1 ]]; then return 1; fi
+  local file="${1}"
+  if [[ ${file:0:2} != "//" ]]; then local file="//depot/online/makefds/mainline/${file}"; fi
+  # Get only lines with a change source (no integrate/branch)
+  # Pull the name of each submitter
+  # Uniqueify without losing order
+  # Attach a number to them
+  p4 filelog "${file}" | \
+    grep -E "^\.\.\. #" | \
+    awk '{ print $9 }' | cut -d'@' -f1 | \
+    perl -ne 'if (!defined $x{$_}) { print $_; $x{$_} = 1; }' | \
+    awk 'BEGIN { idx=1 } { print idx,$0; idx += 1 }'
+}
+
+p4backout() {
+  local changenum="$1"
+  local target_stage="${2:-fdsparent}"
+  local lastchange=$((changenum-1))
+  p4 sync @$lastchange
+  p4 edit ...
+  p4 sync @$changenum
+  p4 resolve -ay
+  p4 sync @$target_stage
+  p4 resolve -am
+}
+
+p4_import_changelist() {
+  local changelist="${1}"
+  local tmpfile=$(mktemp)
+  trap "rm -f ${tmpfile}" EXIT
+
+  p4 client -o > "${tmpfile}"
+
+  local client=$(grep -E "^Client:" "${tmpfile}" | awk '{ print $2 }')
+  local files=($(IFS=$'\n'; p4 describe -s "${changelist}" | grep -E "^\.\.\." | cut -d' ' -f2- | cut -d'#' -f1))
+
+  local has_view=$(grep -c -E "^View:" "${tmpfile}")
+  if [[ $has_view -eq 0 ]]
+  then
+    echo "View:" >> "${tmpfile}"
+  fi
+
+  for file in "${files[@]}"
+  do
+    local mapping="//${client}/${file##*/}"
+    echo -e "\t${file} ${mapping}" >> "${tmpfile}"
+  done
+
+  p4 client -i < "${tmpfile}"
+}
+
+. ${HOME}/.complete-p4
+

+ 98 - 0
profile-util

@@ -0,0 +1,98 @@
+
+PATH="$HOME/usr/local/bin:$HOME/bin:$HOME/usr/bin:$PATH"
+export PATH
+export LC_ALL=en_US.UTF-8
+
+if [ -z "$BASEPATH" ]
+then
+  export BASEPATH="$PATH"
+fi
+
+alias reset-path="export PATH=\"$BASEPATH\""
+
+detach() {
+  for i; do [ -L "$i" ] && cp --remove-destination `readlink "$i"` "$i"; done
+}
+
+link-tools() {
+  PATH=$HOME/tools/bin:$HOME/tools/usr/bin:$PATH
+  LD_LIBRARY_PATH=$HOME/tools/lib:$HOME/tools/usr/lib:$LD_LIBRARY_PATH
+  export PATH
+  export LD_LIBRARY_PATH
+}
+
+unlink-tools() {
+  PATH=$(echo $PATH | perl -pne "s/(?<=:)$HOME/tools.*://g")
+  LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | perl -pne "s/(?<=:)$HOME/tools.*://g")
+  export PATH
+  export LD_LIBRARY_PATH
+}
+
+alias list="ls -lFh --color"
+alias listall="list -A"
+alias git-graph="git log --graph --pretty=oneline --abbrev-commit --decorate --all"
+alias disk-usage="ls -A | xargs du -shc | sort -h"
+
+alias reload="source ~/.profile-user"
+
+refreshterm() {
+  clear
+  uname -a
+  cat /etc/motd
+  echo ""
+  pwd
+  list
+}
+
+export EDITOR=/home/user/wreed/bin/vim
+
+_mkcd_fun() {
+  if [ ! -d "$2" ]; then
+    if [ -e "$2" ]; then
+      echo "mkcd: file exists and is not a directory"
+      exit
+    else
+      $1 "$2"
+    fi
+  fi
+  cd "$2"
+}
+alias mkcd="_mkcd_fun mkdir"
+
+mkdirs() {
+  mkdir -p "$1"
+}
+alias mkcds="_mkcd_fun mkdirs_fun"
+
+alias diffr="diff --ignore-blank-lines --minimal --side-by-side --report-identical-files --suppress-common-lines"
+
+_recall_fun() {
+  if [ -z "$1" ]; then echo "recall: usage: recall string"; return 1; fi
+  history | cut -c 8- | grep --extended-regexp "$1" | \
+    grep --invert-match --extended-regexp "^(history|recall|redo)" | sort | uniq
+}
+
+redo() {
+  IFS=$'\n'
+  hist=($(_recall_fun $1))
+  for ((i=0; i<${#hist[@]}; i++));
+  do
+      echo "[$i] ${hist[$i]}"
+  done
+  printf "Index: "
+  read idx
+  if [[ $idx =~ ^[0-9]+$ ]];
+  then
+      eval "${hist[$idx]}"
+  fi
+  unset IFS
+}
+
+recall(){
+  _recall_fun $1 | sed 's/^/  /'
+}
+
+alias coms="~sjaffe/tools/comstore/commands.sh"
+
+source ${HOME}/.profile-p4
+

+ 120 - 0
tmux.conf

@@ -0,0 +1,120 @@
+#Prefix is Ctrl-a
+set -g prefix C-a
+bind C-a send-prefix
+unbind C-b
+
+setw -g utf8 on
+setw -g status-utf8 on
+
+# set -g default-command "bash -l"
+set -sg escape-time 1
+set -g base-index 1
+setw -g pane-base-index 1
+
+#Mouse works as expected
+setw -g mode-mouse on
+set -g mouse-select-pane on
+set -g mouse-resize-pane on
+set -g mouse-select-window on
+
+setw -g monitor-activity on
+set -g visual-activity on
+
+set -g mode-keys vi
+set -g history-limit 10000
+
+# y and p as in vim
+bind Escape copy-mode
+unbind p
+bind p paste-buffer
+bind -t vi-copy 'v' begin-selection
+bind -t vi-copy 'y' copy-selection
+#bind -t vi-copy 'Space' halfpage-down
+#bind -t vi-copy 'Bspace' halfpage-up
+
+# extra commands for interacting with the ICCCM clipboard
+bind C-c run "tmux save-buffer - | xclip -i -sel clipboard"
+bind C-v run "tmux set-buffer \"$(xclip -o -sel clipboard)\"; tmux paste-buffer"
+
+# easy-to-remember split pane commands
+bind | split-window -h
+bind - split-window -v
+# bind-key c new-window -n 'bash'
+unbind '"'
+unbind %
+
+# moving between panes with vim movement keys
+bind h select-pane -L
+bind j select-pane -D
+bind k select-pane -U
+bind l select-pane -R
+
+# moving between windows with vim movement keys
+bind -r C-h select-window -t :-
+bind -r C-l select-window -t :+
+
+# resize panes with vim movement keys
+bind -r H resize-pane -L 5
+bind -r J resize-pane -D 5
+bind -r K resize-pane -U 5
+bind -r L resize-pane -R 5
+
+bind R source-file ~/.tmux.conf \; display-message "Config reloaded..."
+bind C-n new-session -n 'vim' -s '%%'
+
+# set 256 color
+set -g default-terminal "screen-256color"
+set-window-option -g xterm-keys on
+
+# ----------------------
+# Status Bar
+# -----------------------
+set-option -g status on                # turn the status bar on
+set -g utf8 on
+set -g status-utf8 on                  # set utf-8 for the status bar
+set -g status-interval 5               # set update frequencey (default 15 seconds)
+# set-option -g status-position top    # position the status bar at top of screen
+
+# visual notification of activity in other windows
+setw -g monitor-activity on
+set -g visual-activity on
+
+## set color for status bar
+#set-option -g status-bg green #base02
+#set-option -g status-fg black #yellow
+#set-option -g status-attr dim 
+
+## set window list colors - red for active and cyan for inactive
+#set-window-option -g window-status-fg brightblue #base0
+#set-window-option -g window-status-bg colour236 
+#set-window-option -g window-status-attr dim
+
+#set-window-option -g window-status-current-fg brightred #orange
+#set-window-option -g window-status-current-bg colour236 
+#set-window-option -g window-status-current-attr bright
+
+## show host name and IP address on left side of status bar
+#set -g status-left-length 70
+#set -g status-left "#[fg=black]: #S :"
+
+## show session name, window & pane number, date and time on right side of
+## status bar
+#set -g status-right-length 60
+#set -g status-right "#[fg=black]\"#H\" :: %d %b %Y :: %l:%M %p ::"
+
+set -g @tpm_plugins '           \
+  tmux-plugins/tpm              \
+  tmux-plugins/tmux-resurrect   \
+  tmux-plugins/tmux-copycat     \
+  tmux-plugins/tmux-continuum   \
+'
+run-shell '~/.tmux/plugins/tpm/tpm'
+run-shell '~/.tmux/plugins/tmux-resurrect/resurrect.tmux'
+
+## Resurrect
+set -g @resurrect-strategy-vim 'session'
+set -g @resurrect-strategy-nvim 'session'
+
+# continuum
+set -g @continuum-save-interval '15'
+set -g @continuum-restore 'on'