Skip to content

Instantly share code, notes, and snippets.

marczych / file-pager
Last active Jul 15, 2019
Bash script to open a file or URL in a pager
View file-pager
#!/usr/bin/env bash
set -euo pipefail
if [[ $# == 0 || $1 == "-h" || $1 == "--help" ]]; then
echo "Usage: $0 file"
exit 0
git branch -r --merged | egrep -v "(^\*|master|dev)" | sed -E 's#^.*origin/(.*)$#:\1#' | xargs git push origin
View gist:6422c4fd76f2ee015e4b
rsync -az --delete --exclude=.git -e 'ssh -i <identity file>' src user@host:dest
marczych / gist:10524654
Last active Aug 29, 2015
Tmux git-scripts functions
View gist:10524654
# Convenience functions to set the tmux session name based on branches/pull
# numbers and switches branches based on the session name.
# Depends on tmux and
# (feature|hotfix) switch based on the session name.
function tswitch {
BRANCH=$(tmux display-message -p '#S' | sed 's/|.*$//')
marczych /
Last active Mar 9, 2016
This is a workaround for `android:showAsAction="withText"` not displaying text on narrow layouts e.g. in portrait on phones. This uses styles found in ActionBarSherlock so it matches the native styling. I tested it with ABS v4.4.0 but earlier versions are probably compatible.Note: This should only be used if you absolutely have to display the te…
public class MyActivity extends Activity {
public boolean onCreateOptionsMenu(Menu menu) {
// Trigger onOptionsItemSelected for the custom menu item because it doesn't
// happen automatically.
final MenuItem item = menu.findItem(;
barcodeItem.getActionView().setOnClickListener(new OnClickListener() {
marczych / gist:3882918
Created Oct 13, 2012
Vim: Take the word under the cursor, append the current buffer's extension, and open it using find.
View gist:3882918
nnoremap <silent> <C-o> :call FindFile()<CR>
function! FindFile()
" Get the word under cursor.
let cursorWord = expand("<cword>")
" Get the current file name and keep only the extension.
let currentFile = expand("%")
let extPos = stridx(currentFile, ".")
" Append an extension only if the current file has an extension.