working-directory

AppleScript: how to get the current directory of the topmost Terminal

痴心易碎 提交于 2019-12-02 09:03:30
I want to get the current directory of the topmost Terminal tab/window (via AppleScript or something else, it doesn't really matter). How can I do that? Another solution. get_foregroundterminal_curdir_fast.scpt: tell application "Terminal" do shell script "lsof -a -p `lsof -a -c bash -u $USER -d 0 -n | tail -n +2 | awk '{if($NF==\"" & (tty of front tab of front window) & "\"){print $2}}'` -d cwd -n | tail -n +2 | awk '{print $NF}'" end tell I use lsof itself to get PID of the bash shell of the corresponding Terminal window. This is MUCH faster than using fuser (milliseconds vs. seconds). I got

How does WPF OpenFileDialog track directory of last opened file?

浪子不回头ぞ 提交于 2019-12-02 01:17:22
As we know WPF OpenFileDialog no more changes the app's working directory and RestoreDirectory property is "unimplemented". However, upon subsequent open, its initial directory is default to the last opened file rather than the original working directory, so this information must be stored somewhere. I wonder is it possible to get/set it from user code? nick_w On Windows 7 the recent file information is stored in the registry at this key: HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Comdlg32\OpenSaveMRU Beneath this key are subkeys for the various file extensions (e.g., exe , docx ,

How to set the current working directory in Dart? [duplicate]

吃可爱长大的小学妹 提交于 2019-12-01 20:07:41
This question already has an answer here: How do I find the current directory, in Dart? 1 answer In a dart console application, how do I set the current working directory? import 'dart:io'; ... Directory.current = new Directory('your/path/here'); or just Directory.current = 'your/path/here'; See also https://api.dartlang.org/133671/dart-io/Directory/current.html 来源: https://stackoverflow.com/questions/33020117/how-to-set-the-current-working-directory-in-dart

R list.files(my_working_directory) shows no files but I know they are there. How to fix?

社会主义新天地 提交于 2019-12-01 18:44:36
问题 I'm trying to work with R using a directory in my external hard drive as working directory. I can set the working directory to where I want, but when I use list.files R can't see anything. I also can't use read.delim to load a file. For example: > rm(list = ls()) > WD<-"../../../Volumes/My_HD/my_working_directory" > setwd(WD) > getwd() [1] "/Volumes/My_HD/my_working_directory" So far so good, but then: > list.files(WD) character(0) Whilst I would expect a list of the files that I know are

R list.files(my_working_directory) shows no files but I know they are there. How to fix?

一个人想着一个人 提交于 2019-12-01 18:03:51
I'm trying to work with R using a directory in my external hard drive as working directory. I can set the working directory to where I want, but when I use list.files R can't see anything. I also can't use read.delim to load a file. For example: > rm(list = ls()) > WD<-"../../../Volumes/My_HD/my_working_directory" > setwd(WD) > getwd() [1] "/Volumes/My_HD/my_working_directory" So far so good, but then: > list.files(WD) character(0) Whilst I would expect a list of the files that I know are there and that I can see and open with Finder and with the Terminal. Actually the R script itself is

Command for “Set working directory to source file location”

风流意气都作罢 提交于 2019-12-01 15:21:27
RStudio has a useful feature: Session -> Set Working Directory -> To Source File Location Is there a way to do this without using the drop down menus? UPDATE: maybe a better way of asking is: is there a command to return the file path of the current r script? I also found this thread, but the solutions didn't work for me. Not even Hadley's! Rscript: Determine path of the executing script Romain You can use : source("script.R", chdir = TRUE) and change "script.R" by the name of the file you're interested in. Ciro pathwd<-sub("/filename","",system("find -perm -g=w -type f -name 'filename'"

Why does checkout sometimes stage a file?

情到浓时终转凉″ 提交于 2019-12-01 09:24:59
When I first started using Git, I found the checkout command quite confusing. However, as I adapted to Git's model of version control, it started to make sense. Now I am having to teach Git to my coworkers, and I'm trying to explain checkout simply. I thought I had a simple explanation (from the documentation ): Checkout a branch or paths to the working tree That seems to unify some of the things you can do with checkout which seem like a diverse set of operations to someone new to Git: git checkout . git checkout HEAD . git checkout HEAD~2 git checkout feature/update-readme README.md ..

How to set default working directory in Emacs - troubleshooting

百般思念 提交于 2019-11-30 12:42:11
问题 I know this has been posted many times, but the solutions are not working for me. I've tried the following solutions from this post (Changing the default folder in Emacs): Solution 1: Add (cd "C:/Users/Name/Desktop") to the .emacs file Solution 2: Add (setq default-directory "C:/Documents and Settings/USER NAME/Desktop/" ) to the .emacs file Solution 3: Right click the emacs short cut, hit properties and change the start in field to the desired directory. and only solution 3 is working.

How to get R to recognize your working directory as its working directory?

夙愿已清 提交于 2019-11-30 12:14:40
问题 I use R under Windows on several machines. I know you can set the working directory from within an R script, like this setwd("C:/Documents and Settings/username/My Documents/x/y/z") ... but then this breaks the portability of the script. It's also annoying to have to reverse all the slashes (since Windows gives you backslashes) Is there a way to start R in a particular working directory so that you don't need to do this at the script level? 回答1: You should copy shortcut to R (R.lnk file) to

Upstart node.js working directory

别来无恙 提交于 2019-11-30 11:49:10
Starting Node.js with Upstart, when trying to access files within Node.js it cannot access them without using the full path. I need it to use the working directory. start on startup stop on shutdown script echo $$ > /var/run/mynodeapp.pid exec sudo -u mynodeapp node server.js >> /var/log/mynodeapp.sys.log 2>&1 end script pre-start script echo "Starting" >> /var/log/mynodeapp.sys.log end script pre-stop script rm /var/run/mynodeapp.pid echo "Stopping" >> /var/log/mynodeapp.sys.log end script The solution is to change directory within the script. In my case, the user is mynodeapp and the node