瀏覽代碼

Adding p4finish to clean up after a perforce client is no longer needed.
Adding clear for tmux.
Adding a swapfile function.

Sam Jaffe 9 年之前
父節點
當前提交
579ae0c753
共有 2 個文件被更改,包括 38 次插入0 次删除
  1. 22 0
      profile-p4
  2. 16 0
      profile-util

+ 22 - 0
profile-p4

@@ -65,5 +65,27 @@ p4_import_changelist() {
   p4 client -i < "${tmpfile}"
 }
 
+p4finish() { 
+  local cwd="${PWD}"
+  local rmdir=0
+  if [[ ${1} == "-d"  ]]; then rmdir=1; shift; fi
+  local tar="${1}" 
+  if [[ -z ${tar}  ]] || [[ ! -d ${tar}  ]]; then
+    echo "Directory does not exist: '${tar}'"
+    return 1
+  fi
+  cd "${tar}"
+  if [[ $(p4 opened 2>/dev/null) == ""  ]]; then
+    p4 sync ...#0
+    cd "${cwd}"
+    [[ ${rmdir} -eq 1  ]] && rm -rf "${tar}"
+  else
+    echo "Perforce client has open files"
+    cd "${cwd}"
+    return 1
+  fi
+}
+
+
 . ${HOME}/.complete-p4
 

+ 16 - 0
profile-util

@@ -96,6 +96,22 @@ recall(){
   _recall_fun $1 | sed 's/^/  /'
 }
 
+clear() {
+  /usr/bin/clear
+  if [[ ! -z "${TMUX}" ]]; then tmux clear-history; fi
+}
+
+swap() {
+  if [[ $# -ne 2 ]]; then
+    echo "swap file1 file2" >&2
+    return 1
+  fi
+  local tmpfile=$(mktemp)
+  mv "${1}" "${tmpfile}"
+  mv "${2}" "${1}"
+  mv "${tmpfile}" "${2}"
+}
+
 alias coms="${HOME}/tools/comstore/commands.sh"
 
 source ${HOME}/.profile-p4