Skip to content

Instantly share code, notes, and snippets.

View meta_comments
relpath(){ python -c "import os.path; print os.path.relpath('$1','${2:-$PWD}')" ; }
show_latest () {
if [ -z "$1" ]
then
local dir=$PWD
else
local dir="$1"
fi
ls --sort=time --reverse "$dir" | tail -1 ;
}
@RaghavRao
RaghavRao / new_script.sh
Last active Aug 16, 2018
Create a new script by executing "which".
View new_script.sh
#!/bin/bash
# Append to ~/.bashrc
# Usage:
# Default editor from /etc/alternatives/editor: $ nf python ~/scripy.py
# Custom editor: $ nf python ~/script.py vi
nf() {
STR=$( echo "#!"`which "$1"` )
if [ ! -f "$2" ]; then
echo $STR > "$2"
echo "" >> "$2"
You can’t perform that action at this time.