I've also wondered to myself why there isn't a terminal program with a directory tree by the side so you could just click on the directory that you want to be in, instead of ls -cd-tab-blah-^H-tab-^M. It would also a have a list of favorite and most-recently-used directories. A weekend project, perhaps...
Don't waste your time by cd-ing in the terminal
111–120 of 124 posts
Re: Don't waste your time by cd-ing in the terminal
#112http://geocities.com/h2428/petar/bash_acd.htm
http://geocities.com/h2428/petar/bash_hist.htm
highly recommended.
Re: Don't waste your time by cd-ing in the terminal
#1131. How about we just learning to type fast(-er) and use file name completion 2. Use real shell like ksh, where history search actually works 3. cd $OLDPWD is occasionally helpful. Occasionally. Kids...
Re: Don't waste your time by cd-ing in the terminal
#114Earlier quoted context omitted.
I've also been frustrated by these issues. I want to be able to edit a file with local typing speed (i.e., gvim on Windows), but then be able to hit a key and be in a terminal window on that server in that folder to perhaps do a manual grep or rebuild an index or whatever. I feel like we were closer in the 90s with innovative products like Slirp and Term and, yes, Zmodem (and Kermit). I started trying to build out so…
Sounds like you want Emacs' tramp. On your local emacs, open a file in the form "/user@remote-ssh-host:file" and it will grab the remote file and edit it locally. Crazily all the emacs version control commands and stuff like M-x compile and M-x grep all work in the remote context. Very cool stuff. Obviously this requires that you use Emacs instead of Vim though. Don't be afraid though, the grass is pretty green over…
Vim has this functionality built right in: http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html#netrw
However, as said above, for me Tramp/netrw are kludges that tend to add more problems than they solve. A real solution can't be constrained to a particular editor.
Re: Don't waste your time by cd-ing in the terminal
#115Earlier quoted context omitted.
Or in zsh: setopt cdablevars nm=/path/to/whatever cd nm
you can put this in ~/.zshrc for persistent zsh bookmarks touch ~/.zshmarks && source ~/.zshmarks function b() { echo "hash -d $1=\"`pwd`\"" >> ~/.zshmarks && source ~/.zshmarks }
Re: Don't waste your time by cd-ing in the terminal
#116For example:
cd /Users/username/Library/Application\ Support
s app_support
works great but if you do this it won't work: g app_support
I opened an issue on GitHub and after that I tried to fix it on my own. I never wrote a bash script and I'm really proud to have fixed this problem on my own.Here are changes I made:
# save current directory to bookmarks
touch ~/.sdirs
function s {
cat ~/.sdirs | grep -v "export DIR_$1=" > ~/.sdirs1
mv ~/.sdirs1 ~/.sdirs
escaped_path=${PWD/ /\\ }
echo "export DIR_$1=$escaped_path" >> ~/.sdirs
}
# jump to bookmark
function g {
source ~/.sdirs
path=$(eval $(echo echo $(echo \$DIR_$1)))
# replace whitespaces with "\ " for escaping
escaped_path=${path/ /\\ }
cd_eval="cd $escaped_path"
eval $cd_eval
}
Hope this helps you guys like it helped me.
And if there is a way to do this in an more elegant way, please let me know. This would help me to improve my none existing bash skills :DEdit: I opened up a fork and commited all my changes to this repo. I also opened a pull request and I hope my fix will get accepted.
GitHub fork: https://github.com/Oemera/bashmarks
Thanks
Ömer
Re: Don't waste your time by cd-ing in the terminal
#117Earlier quoted context omitted.
You can also use the "dirs" command (I think part of bash as well) that tells you the state of the stack. If you set the -v option, you can get the depth of different directories, and you can just do pushd +N to jump to the specific directory.
funny- I don't see man pages (nor info pages) for pushd, popd, or dirs. What am I missing about the documentation?
Re: Don't waste your time by cd-ing in the terminal
#118Earlier quoted context omitted.
funny- I don't see man pages (nor info pages) for pushd, popd, or dirs. What am I missing about the documentation?
They're shell built-ins, so use "man bash" to read about them.
help Re: Don't waste your time by cd-ing in the terminal
#119Don't waste your time bookmarking directories, jump right to them ;) https://github.com/rupa/z `z` tracks your most used directories. After a short learning phase, it will take you to the directory, based on its usage frequency and a hint you give it on the command line. Say I am often cd'ing into /var/www - then after a while I can just type `z ww`.
I've created an AUR package for this script, found here: http://aur.archlinux.org/packages.php?ID=46675
Re: Don't waste your time by cd-ing in the terminal
#120I've also wondered to myself why there isn't a terminal program with a directory tree by the side so you could just click on the directory that you want to be in, instead of ls -cd-tab-blah-^H-tab-^M. It would also a have a list of favorite and most-recently-used directories. A weekend project, perhaps...
Unrelated but a nice alias "tree". alias tree="find . -name .svn -prune -o -name .DS_Store -prune -o -name .git -prune -o -print | sed -e 's;[^/]*/;|___;g;s;___|; |;g'" It shows your directory listing in the form of a tree. Easier to visualize.