Using CLI and GUI Together Seemlessly
Some people love CLI like heaven, hate GUI like hell, and vice verser for some other people.
Me? I used to belong to the first group, but now I have learned to another level. Why not stop the love and hate and make them work together?
For e.g., now I often start from the CLI, and end in the GUI. If I want to open a file for uploading in GUI browser, I start from the CLI shell, because navigating directories and searching for files is so much easier in CLI shell than clicking all the way down the directory hierarchy in GUI FindFile dialog. Then I, while still in CLI shell, put the file path into clipboard with xclip (for Linux) or putclip (for Cygwin), switch back to the browser FindFile dialog, and paste it.
Similarly, when I want to locate a file in FileManager like Explorer for e.g., I start from the shell with this bash function:
function oc() { cygstart `which explorer.exe` /n,/select,\""`cygpath -alw \"$1\"`"\" }
When I want to locate a registry entry in regedit.exe, I use another command I wrote in python and pywin32, and made a short name of in bash:
alias or=regopen.py #open registry
When I want open a file with its associated opener, like Word for .doc, Excel for .xls, I use cygstart in Cygwin, and gnome-open in Linux:
if test `uname` = CYGWIN_NT-5.1 -o `uname` = CYGWIN_NT-6.1 then function of() { if test -e "$1"; then cygstart "$@" return fi if which "$1" >/dev/null 2>&1; then if [[ "$1" == of ]]; then local file=`which cygstart` else local file="`which \"$1\"`" fi shift cygstart "$file" "$@" else cygstart "$@" fi } else alias of=gnome-open fi
This way, I can use the same .bashrc under both Linux and Windows
(think, Cygwin), and the same (well, not completely) of
command to
Open File.
(So this is not just about CLI/GUI together, but also about using Linux/Windows (again, think Cygwin) in the maximally possible same way).